Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(334)

Side by Side Diff: components/invalidation/push_client_channel.h

Issue 1191393008: Introduce a layering in the invalidation component as public and impl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Explicitly forbid content to prevent future additions Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_INVALIDATION_PUSH_CLIENT_CHANNEL_H_
6 #define COMPONENTS_INVALIDATION_PUSH_CLIENT_CHANNEL_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "components/invalidation/invalidation_export.h"
14 #include "components/invalidation/sync_system_resources.h"
15 #include "jingle/notifier/listener/push_client_observer.h"
16
17 namespace notifier {
18 class PushClient;
19 } // namespace notifier
20
21 namespace syncer {
22
23 // A PushClientChannel is an implementation of NetworkChannel that
24 // routes messages through a PushClient.
25 class INVALIDATION_EXPORT_PRIVATE PushClientChannel
26 : public SyncNetworkChannel,
27 public NON_EXPORTED_BASE(notifier::PushClientObserver) {
28 public:
29 // |push_client| is guaranteed to be destroyed only when this object
30 // is destroyed.
31 explicit PushClientChannel(scoped_ptr<notifier::PushClient> push_client);
32
33 ~PushClientChannel() override;
34
35 // invalidation::NetworkChannel implementation.
36 void SendMessage(const std::string& message) override;
37 void RequestDetailedStatus(
38 base::Callback<void(const base::DictionaryValue&)> callback) override;
39
40 // SyncNetworkChannel implementation.
41 // If not connected, connects with the given credentials. If
42 // already connected, the next connection attempt will use the given
43 // credentials.
44 void UpdateCredentials(const std::string& email,
45 const std::string& token) override;
46 int GetInvalidationClientType() override;
47
48 // notifier::PushClient::Observer implementation.
49 void OnNotificationsEnabled() override;
50 void OnNotificationsDisabled(
51 notifier::NotificationsDisabledReason reason) override;
52 void OnIncomingNotification(
53 const notifier::Notification& notification) override;
54
55 const std::string& GetServiceContextForTest() const;
56
57 int64 GetSchedulingHashForTest() const;
58
59 static std::string EncodeMessageForTest(const std::string& message,
60 const std::string& service_context,
61 int64 scheduling_hash);
62
63 static bool DecodeMessageForTest(const std::string& notification,
64 std::string* message,
65 std::string* service_context,
66 int64* scheduling_hash);
67
68 private:
69 static void EncodeMessage(std::string* encoded_message,
70 const std::string& message,
71 const std::string& service_context,
72 int64 scheduling_hash);
73 static bool DecodeMessage(const std::string& data,
74 std::string* message,
75 std::string* service_context,
76 int64* scheduling_hash);
77 scoped_ptr<base::DictionaryValue> CollectDebugData() const;
78
79 scoped_ptr<notifier::PushClient> push_client_;
80 std::string service_context_;
81 int64 scheduling_hash_;
82
83 // This count is saved for displaying statatistics.
84 int sent_messages_count_;
85
86 DISALLOW_COPY_AND_ASSIGN(PushClientChannel);
87 };
88
89 } // namespace syncer
90
91 #endif // COMPONENTS_INVALIDATION_PUSH_CLIENT_CHANNEL_H_
OLDNEW
« no previous file with comments | « components/invalidation/public/single_object_invalidation_set.cc ('k') | components/invalidation/push_client_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698