| OLD | NEW |
| 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> |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // int: The HTTP status code of the response. | 42 // int: The HTTP status code of the response. |
| 43 // string: The contents of the response. | 43 // string: The contents of the response. |
| 44 using PostCleanupCallback = base::Callback<void(HttpPost*, | 44 using PostCleanupCallback = base::Callback<void(HttpPost*, |
| 45 int, | 45 int, |
| 46 const std::string&)>; | 46 const std::string&)>; |
| 47 | 47 |
| 48 // Callback to allow tests to stub out HTTP POST behavior. | 48 // Callback to allow tests to stub out HTTP POST behavior. |
| 49 // Arguments: | 49 // Arguments: |
| 50 // URLRequestContextGetter: Context for the HTTP POST request. | 50 // URLRequestContextGetter: Context for the HTTP POST request. |
| 51 // string: Name of the rpc to invoke. URL format: server.google.com/rpc_name | 51 // string: Name of the rpc to invoke. URL format: server.google.com/rpc_name |
| 52 // string: The API key to pass in the request. Deprecated. | 52 // string: The API key to pass in the request. |
| 53 // string: The auth token to pass with the request. | 53 // string: The auth token to pass with the request. |
| 54 // MessageLite: Contents of POST request to be sent. This needs to be | 54 // MessageLite: Contents of POST request to be sent. This needs to be |
| 55 // a (scoped) pointer to ease handling of the abstract MessageLite class. | 55 // a (scoped) pointer to ease handling of the abstract MessageLite class. |
| 56 // PostCleanupCallback: Receives the response to the request. | 56 // PostCleanupCallback: Receives the response to the request. |
| 57 using PostCallback = base::Callback<void( | 57 using PostCallback = base::Callback<void( |
| 58 net::URLRequestContextGetter*, | 58 net::URLRequestContextGetter*, |
| 59 const std::string&, | 59 const std::string&, |
| 60 const std::string&, | 60 const std::string&, |
| 61 const std::string&, | 61 const std::string&, |
| 62 scoped_ptr<google::protobuf::MessageLite>, | 62 scoped_ptr<google::protobuf::MessageLite>, |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 const std::string& device_id, | 150 const std::string& device_id, |
| 151 const std::string& app_id, | 151 const std::string& app_id, |
| 152 bool authenticated, | 152 bool authenticated, |
| 153 scoped_ptr<T> request, | 153 scoped_ptr<T> request, |
| 154 const PostCleanupCallback& response_handler); | 154 const PostCleanupCallback& response_handler); |
| 155 | 155 |
| 156 // Wrapper for the http post constructor. This is the default way | 156 // Wrapper for the http post constructor. This is the default way |
| 157 // to contact the server, but it can be overridden for testing. | 157 // to contact the server, but it can be overridden for testing. |
| 158 void SendHttpPost(net::URLRequestContextGetter* url_context_getter, | 158 void SendHttpPost(net::URLRequestContextGetter* url_context_getter, |
| 159 const std::string& rpc_name, | 159 const std::string& rpc_name, |
| 160 const std::string& api_key, // Deprecated | 160 const std::string& api_key, |
| 161 const std::string& auth_token, | 161 const std::string& auth_token, |
| 162 scoped_ptr<google::protobuf::MessageLite> request_proto, | 162 scoped_ptr<google::protobuf::MessageLite> request_proto, |
| 163 const PostCleanupCallback& callback); | 163 const PostCleanupCallback& callback); |
| 164 | 164 |
| 165 // These belong to the caller. | 165 // These belong to the caller. |
| 166 CopresenceDelegate* const delegate_; | 166 CopresenceDelegate* const delegate_; |
| 167 CopresenceStateImpl* state_; | 167 CopresenceStateImpl* state_; |
| 168 DirectiveHandler* const directive_handler_; | 168 DirectiveHandler* const directive_handler_; |
| 169 GCMHandler* const gcm_handler_; | 169 GCMHandler* const gcm_handler_; |
| 170 | 170 |
| 171 MessagesCallback new_messages_callback_; | 171 MessagesCallback new_messages_callback_; |
| 172 PostCallback server_post_callback_; | 172 PostCallback server_post_callback_; |
| 173 | 173 |
| 174 ScopedVector<PendingRequest> pending_requests_queue_; | 174 ScopedVector<PendingRequest> pending_requests_queue_; |
| 175 TimedMap<std::string, bool> invalid_audio_token_cache_; | 175 TimedMap<std::string, bool> invalid_audio_token_cache_; |
| 176 std::set<HttpPost*> pending_posts_; | 176 std::set<HttpPost*> pending_posts_; |
| 177 std::set<bool> pending_registrations_; | 177 std::set<bool> pending_registrations_; |
| 178 std::string auth_token_; | 178 std::string auth_token_; |
| 179 std::string gcm_id_; | 179 std::string gcm_id_; |
| 180 | 180 |
| 181 DISALLOW_COPY_AND_ASSIGN(RpcHandler); | 181 DISALLOW_COPY_AND_ASSIGN(RpcHandler); |
| 182 }; | 182 }; |
| 183 | 183 |
| 184 } // namespace copresence | 184 } // namespace copresence |
| 185 | 185 |
| 186 #endif // COMPONENTS_COPRESENCE_RPC_RPC_HANDLER_H_ | 186 #endif // COMPONENTS_COPRESENCE_RPC_RPC_HANDLER_H_ |
| OLD | NEW |