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

Side by Side Diff: components/copresence/rpc/rpc_handler.h

Issue 764673003: Adding CopresenceState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing overzealous DCHECK Created 6 years 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_COPRESENCE_RPC_RPC_HANDLER_H_ 5 #ifndef COMPONENTS_COPRESENCE_RPC_RPC_HANDLER_H_
6 #define COMPONENTS_COPRESENCE_RPC_RPC_HANDLER_H_ 6 #define COMPONENTS_COPRESENCE_RPC_RPC_HANDLER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback_forward.h" 13 #include "base/callback_forward.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/scoped_vector.h" 15 #include "base/memory/scoped_vector.h"
16 #include "components/copresence/proto/enums.pb.h" 16 #include "components/copresence/proto/enums.pb.h"
17 #include "components/copresence/public/copresence_delegate.h" 17 #include "components/copresence/public/copresence_delegate.h"
18 #include "components/copresence/timed_map.h" 18 #include "components/copresence/timed_map.h"
19 19
20 namespace copresence { 20 namespace copresence {
21 21
22 struct AudioToken; 22 struct AudioToken;
23 class CopresenceDelegate; 23 class CopresenceDelegate;
24 class CopresenceStateImpl;
24 class DirectiveHandler; 25 class DirectiveHandler;
25 class GCMHandler; 26 class GCMHandler;
26 class HttpPost; 27 class HttpPost;
27 class ReportRequest; 28 class ReportRequest;
28 class RequestHeader; 29 class RequestHeader;
29 class SubscribedMessage; 30 class SubscribedMessage;
30 31
31 // This class currently handles all communication with the copresence server. 32 // This class currently handles all communication with the copresence server.
32 class RpcHandler { 33 class RpcHandler {
33 public: 34 public:
(...skipping 24 matching lines...) Expand all
58 scoped_ptr<google::protobuf::MessageLite>, 59 scoped_ptr<google::protobuf::MessageLite>,
59 const PostCleanupCallback&)> PostCallback; 60 const PostCleanupCallback&)> PostCallback;
60 61
61 // Report rpc name to send to Apiary. 62 // Report rpc name to send to Apiary.
62 static const char kReportRequestRpcName[]; 63 static const char kReportRequestRpcName[];
63 64
64 // Constructor. |delegate| and |directive_handler| 65 // Constructor. |delegate| and |directive_handler|
65 // are owned by the caller and must outlive the RpcHandler. 66 // are owned by the caller and must outlive the RpcHandler.
66 // |server_post_callback| should be set only by tests. 67 // |server_post_callback| should be set only by tests.
67 RpcHandler(CopresenceDelegate* delegate, 68 RpcHandler(CopresenceDelegate* delegate,
69 CopresenceStateImpl* state,
68 DirectiveHandler* directive_handler, 70 DirectiveHandler* directive_handler,
69 GCMHandler* gcm_handler, 71 GCMHandler* gcm_handler,
70 const PostCallback& server_post_callback = PostCallback()); 72 const PostCallback& server_post_callback = PostCallback());
71 73
72 virtual ~RpcHandler(); 74 virtual ~RpcHandler();
73 75
74 // Send a ReportRequest from a specific app, and get notified of completion. 76 // Send a ReportRequest from a specific app, and get notified of completion.
75 void SendReportRequest(scoped_ptr<ReportRequest> request, 77 void SendReportRequest(scoped_ptr<ReportRequest> request,
76 const std::string& app_id, 78 const std::string& app_id,
77 const std::string& auth_token, 79 const std::string& auth_token,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // to contact the server, but it can be overridden for testing. 154 // to contact the server, but it can be overridden for testing.
153 void SendHttpPost(net::URLRequestContextGetter* url_context_getter, 155 void SendHttpPost(net::URLRequestContextGetter* url_context_getter,
154 const std::string& rpc_name, 156 const std::string& rpc_name,
155 const std::string& api_key, 157 const std::string& api_key,
156 const std::string& auth_token, 158 const std::string& auth_token,
157 scoped_ptr<google::protobuf::MessageLite> request_proto, 159 scoped_ptr<google::protobuf::MessageLite> request_proto,
158 const PostCleanupCallback& callback); 160 const PostCleanupCallback& callback);
159 161
160 // These belong to the caller. 162 // These belong to the caller.
161 CopresenceDelegate* const delegate_; 163 CopresenceDelegate* const delegate_;
164 CopresenceStateImpl* state_;
162 DirectiveHandler* const directive_handler_; 165 DirectiveHandler* const directive_handler_;
163 GCMHandler* const gcm_handler_; 166 GCMHandler* const gcm_handler_;
164 167
165 PostCallback server_post_callback_; 168 PostCallback server_post_callback_;
166 169
167 ScopedVector<PendingRequest> pending_requests_queue_; 170 ScopedVector<PendingRequest> pending_requests_queue_;
168 TimedMap<std::string, bool> invalid_audio_token_cache_; 171 TimedMap<std::string, bool> invalid_audio_token_cache_;
169 std::map<std::string, std::string> device_id_by_auth_token_; 172 std::map<std::string, std::string> device_id_by_auth_token_;
170 std::set<HttpPost*> pending_posts_; 173 std::set<HttpPost*> pending_posts_;
171 std::string gcm_id_; 174 std::string gcm_id_;
172 175
173 DISALLOW_COPY_AND_ASSIGN(RpcHandler); 176 DISALLOW_COPY_AND_ASSIGN(RpcHandler);
174 }; 177 };
175 178
176 } // namespace copresence 179 } // namespace copresence
177 180
178 #endif // COMPONENTS_COPRESENCE_RPC_RPC_HANDLER_H_ 181 #endif // COMPONENTS_COPRESENCE_RPC_RPC_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698