Skip to content

Commit a70c9fa

Browse files
amabluea-maurice
authored andcommitted
Moved PersistentConnection::Tag to a standalone Tag typedef in its own header.
PiperOrigin-RevId: 269854964
1 parent 7c24671 commit a70c9fa

File tree

6 files changed

+43
-9
lines changed

6 files changed

+43
-9
lines changed

database/src/desktop/connection/persistent_connection.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "app/src/time.h"
2727
#include "app/src/variant_util.h"
2828
#include "database/src/desktop/core/constants.h"
29+
#include "database/src/desktop/core/tag.h"
2930
#include "database/src/desktop/util_desktop.h"
3031
#include "database/src/include/firebase/database/common.h"
3132

@@ -352,8 +353,7 @@ void PersistentConnection::ScheduleShutdown() {
352353
}));
353354
}
354355

355-
void PersistentConnection::Listen(const QuerySpec& query_spec,
356-
const Optional<int64_t>& tag,
356+
void PersistentConnection::Listen(const QuerySpec& query_spec, const Tag& tag,
357357
ResponsePtr response) {
358358
CheckAuthTokenAndSendOnChange();
359359
logger_->LogDebug("%s Listening on %s", log_id_.c_str(),

database/src/desktop/connection/persistent_connection.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "database/src/common/query_spec.h"
3636
#include "database/src/desktop/connection/connection.h"
3737
#include "database/src/desktop/connection/host_info.h"
38+
#include "database/src/desktop/core/tag.h"
3839
#include "database/src/include/firebase/database/common.h"
3940

4041
namespace firebase {
@@ -100,7 +101,7 @@ typedef SharedPtr<Response> ResponsePtr;
100101
class PersistentConnection : public ConnectionEventHandler {
101102
public:
102103
// Tag for listen request/response
103-
typedef Optional<int64_t> Tag;
104+
typedef Tag Tag;
104105

105106
explicit PersistentConnection(App* app, const HostInfo& info,
106107
PersistentConnectionEventHandler* event_handler,
@@ -564,8 +565,7 @@ class PersistentConnectionEventHandler {
564565
const std::map<Variant, Variant>& updates) = 0;
565566

566567
virtual void OnDataUpdate(const Path& path, const Variant& payload_data,
567-
bool is_merge,
568-
const PersistentConnection::Tag& tag) = 0;
568+
bool is_merge, const Tag& tag) = 0;
569569
};
570570

571571
} // namespace connection

database/src/desktop/core/repo.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "database/src/desktop/core/constants.h"
2424
#include "database/src/desktop/core/info_listen_provider.h"
2525
#include "database/src/desktop/core/server_values.h"
26+
#include "database/src/desktop/core/tag.h"
2627
#include "database/src/desktop/core/value_event_registration.h"
2728
#include "database/src/desktop/core/web_socket_listen_provider.h"
2829
#include "database/src/desktop/core/write_tree.h"
@@ -541,7 +542,7 @@ void Repo::OnServerInfoUpdate(const std::map<Variant, Variant>& updates) {
541542
}
542543

543544
void Repo::OnDataUpdate(const Path& path, const Variant& data, bool is_merge,
544-
const connection::PersistentConnection::Tag& tag) {
545+
const Tag& tag) {
545546
SAFE_REFERENCE_RETURN_VOID_IF_INVALID(ThisRefLock, lock, safe_this_);
546547

547548
std::vector<Event> events;

database/src/desktop/core/repo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "database/src/desktop/core/event_registration.h"
2727
#include "database/src/desktop/core/sparse_snapshot_tree.h"
2828
#include "database/src/desktop/core/sync_tree.h"
29+
#include "database/src/desktop/core/tag.h"
2930
#include "database/src/desktop/core/tree.h"
3031
#include "database/src/desktop/transaction_data.h"
3132
#include "database/src/desktop/view/event.h"
@@ -102,8 +103,7 @@ class Repo : public connection::PersistentConnectionEventHandler {
102103
void OnServerInfoUpdate(const std::map<Variant, Variant>& updates) override;
103104

104105
void OnDataUpdate(const Path& path, const Variant& payload_data,
105-
bool is_merge,
106-
const connection::PersistentConnection::Tag& tag) override;
106+
bool is_merge, const Tag& tag) override;
107107

108108
const std::string& url() const { return url_; }
109109

database/src/desktop/core/tag.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2019 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifndef FIREBASE_DATABASE_CLIENT_CPP_SRC_DESKTOP_CORE_TAG_H_
16+
#define FIREBASE_DATABASE_CLIENT_CPP_SRC_DESKTOP_CORE_TAG_H_
17+
18+
#include <cstdint>
19+
20+
#include "app/src/optional.h"
21+
22+
namespace firebase {
23+
namespace database {
24+
namespace internal {
25+
26+
typedef Optional<int64_t> Tag;
27+
28+
} // namespace internal
29+
} // namespace database
30+
} // namespace firebase
31+
32+
#endif // FIREBASE_DATABASE_CLIENT_CPP_SRC_DESKTOP_CORE_TAG_H_

database/src/desktop/core/web_socket_listen_provider.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "database/src/common/query_spec.h"
1818
#include "database/src/desktop/connection/persistent_connection.h"
1919
#include "database/src/desktop/core/listen_provider.h"
20+
#include "database/src/desktop/core/tag.h"
2021
#include "database/src/desktop/view/view.h"
2122

2223
namespace firebase {
@@ -56,7 +57,7 @@ class WebSocketListenResponse : public connection::Response {
5657
void WebSocketListenProvider::StartListening(const QuerySpec& query_spec,
5758
const View* view) {
5859
connection_->Listen(
59-
query_spec, PersistentConnection::Tag(),
60+
query_spec, Tag(),
6061
MakeShared<WebSocketListenResponse>(
6162
[](const SharedPtr<connection::Response>& connection_response) {
6263
WebSocketListenResponse* response =

0 commit comments

Comments
 (0)