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 <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // to be called before invoking any other methods. | 43 // to be called before invoking any other methods. |
44 void Initialize(const SuccessCallback& init_done_callback); | 44 void Initialize(const SuccessCallback& init_done_callback); |
45 | 45 |
46 // Send a report request | 46 // Send a report request |
47 void SendReportRequest(scoped_ptr<ReportRequest> request); | 47 void SendReportRequest(scoped_ptr<ReportRequest> request); |
48 void SendReportRequest(scoped_ptr<ReportRequest> request, | 48 void SendReportRequest(scoped_ptr<ReportRequest> request, |
49 const std::string& app_id, | 49 const std::string& app_id, |
50 const StatusCallback& callback); | 50 const StatusCallback& callback); |
51 | 51 |
52 // Report a set of tokens to the server for a given medium. | 52 // Report a set of tokens to the server for a given medium. |
53 void ReportTokens(const std::vector<FullToken>& tokens); | 53 void ReportTokens(const std::vector<AudioToken>& tokens); |
54 | 54 |
55 // Create the directive handler and connect it to | 55 // Create the directive handler and connect it to |
56 // the whispernet client specified by the delegate. | 56 // the whispernet client specified by the delegate. |
57 void ConnectToWhispernet(); | 57 void ConnectToWhispernet(); |
58 | 58 |
59 private: | 59 private: |
60 // An HttpPost::ResponseCallback prepended with an HttpPost object | 60 // An HttpPost::ResponseCallback prepended with an HttpPost object |
61 // that needs to be deleted. | 61 // that needs to be deleted. |
62 typedef base::Callback<void(HttpPost*, int, const std::string&)> | 62 typedef base::Callback<void(HttpPost*, int, const std::string&)> |
63 PostCleanupCallback; | 63 PostCleanupCallback; |
(...skipping 14 matching lines...) Expand all Loading... |
78 | 78 |
79 void RegisterResponseHandler(const SuccessCallback& init_done_callback, | 79 void RegisterResponseHandler(const SuccessCallback& init_done_callback, |
80 HttpPost* completed_post, | 80 HttpPost* completed_post, |
81 int http_status_code, | 81 int http_status_code, |
82 const std::string& response_data); | 82 const std::string& response_data); |
83 void ReportResponseHandler(const StatusCallback& status_callback, | 83 void ReportResponseHandler(const StatusCallback& status_callback, |
84 HttpPost* completed_post, | 84 HttpPost* completed_post, |
85 int http_status_code, | 85 int http_status_code, |
86 const std::string& response_data); | 86 const std::string& response_data); |
87 | 87 |
| 88 // If the request has any unpublish or unsubscribe operations, it removes |
| 89 // them from our directive handlers. |
| 90 void ProcessRemovedOperations(const ReportRequest& request); |
| 91 |
| 92 // Add all currently playing tokens to the update signals in this report |
| 93 // request. This ensures that the server doesn't keep issueing new tokens to |
| 94 // us when we're already playing valid tokens. |
| 95 void AddPlayingTokens(ReportRequest* request); |
| 96 |
88 void DispatchMessages( | 97 void DispatchMessages( |
89 const google::protobuf::RepeatedPtrField<SubscribedMessage>& | 98 const google::protobuf::RepeatedPtrField<SubscribedMessage>& |
90 subscribed_messages); | 99 subscribed_messages); |
91 | 100 |
92 RequestHeader* CreateRequestHeader(const std::string& client_name) const; | 101 RequestHeader* CreateRequestHeader(const std::string& client_name) const; |
93 | 102 |
94 template <class T> | 103 template <class T> |
95 void SendServerRequest(const std::string& rpc_name, | 104 void SendServerRequest(const std::string& rpc_name, |
96 const std::string& app_id, | 105 const std::string& app_id, |
97 scoped_ptr<T> request, | 106 scoped_ptr<T> request, |
(...skipping 20 matching lines...) Expand all Loading... |
118 std::string device_id_; | 127 std::string device_id_; |
119 scoped_ptr<DirectiveHandler> directive_handler_; | 128 scoped_ptr<DirectiveHandler> directive_handler_; |
120 std::set<HttpPost*> pending_posts_; | 129 std::set<HttpPost*> pending_posts_; |
121 | 130 |
122 DISALLOW_COPY_AND_ASSIGN(RpcHandler); | 131 DISALLOW_COPY_AND_ASSIGN(RpcHandler); |
123 }; | 132 }; |
124 | 133 |
125 } // namespace copresence | 134 } // namespace copresence |
126 | 135 |
127 #endif // COMPONENTS_COPRESENCE_RPC_RPC_HANDLER_H_ | 136 #endif // COMPONENTS_COPRESENCE_RPC_RPC_HANDLER_H_ |
OLD | NEW |