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 #include "components/copresence/rpc/rpc_handler.h" | 5 #include "components/copresence/rpc/rpc_handler.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/guid.h" | 11 #include "base/guid.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "components/copresence/copresence_switches.h" | 15 #include "components/copresence/copresence_switches.h" |
16 #include "components/copresence/handlers/directive_handler.h" | 16 #include "components/copresence/handlers/directive_handler.h" |
17 #include "components/copresence/proto/codes.pb.h" | 17 #include "components/copresence/proto/codes.pb.h" |
18 #include "components/copresence/proto/data.pb.h" | 18 #include "components/copresence/proto/data.pb.h" |
19 #include "components/copresence/proto/rpcs.pb.h" | 19 #include "components/copresence/proto/rpcs.pb.h" |
20 #include "components/copresence/public/copresence_client_delegate.h" | 20 #include "components/copresence/public/copresence_delegate.h" |
21 #include "net/http/http_status_code.h" | 21 #include "net/http/http_status_code.h" |
22 | 22 |
23 // TODO(ckehoe): Return error messages for bad requests. | 23 // TODO(ckehoe): Return error messages for bad requests. |
24 | 24 |
25 namespace copresence { | 25 namespace copresence { |
26 | 26 |
27 using google::protobuf::MessageLite; | 27 using google::protobuf::MessageLite; |
28 using google::protobuf::RepeatedPtrField; | 28 using google::protobuf::RepeatedPtrField; |
29 | 29 |
30 const char RpcHandler::kReportRequestRpcName[] = "report"; | 30 const char RpcHandler::kReportRequestRpcName[] = "report"; |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 CreateOptedInOrOutFilter()); | 237 CreateOptedInOrOutFilter()); |
238 } | 238 } |
239 } | 239 } |
240 } | 240 } |
241 } | 241 } |
242 | 242 |
243 } // namespace | 243 } // namespace |
244 | 244 |
245 // Public methods | 245 // Public methods |
246 | 246 |
247 RpcHandler::RpcHandler(CopresenceClientDelegate* delegate) | 247 RpcHandler::RpcHandler(CopresenceDelegate* delegate) |
248 : delegate_(delegate), | 248 : delegate_(delegate), |
249 invalid_audio_token_cache_( | 249 invalid_audio_token_cache_( |
250 base::TimeDelta::FromMilliseconds(kInvalidTokenExpiryTimeMs), | 250 base::TimeDelta::FromMilliseconds(kInvalidTokenExpiryTimeMs), |
251 kMaxInvalidTokens), | 251 kMaxInvalidTokens), |
252 server_post_callback_(base::Bind(&RpcHandler::SendHttpPost, | 252 server_post_callback_(base::Bind(&RpcHandler::SendHttpPost, |
253 base::Unretained(this))) {} | 253 base::Unretained(this))) {} |
254 | 254 |
255 RpcHandler::~RpcHandler() { | 255 RpcHandler::~RpcHandler() { |
256 for (std::set<HttpPost*>::iterator post = pending_posts_.begin(); | 256 for (std::set<HttpPost*>::iterator post = pending_posts_.begin(); |
257 post != pending_posts_.end(); ++post) { | 257 post != pending_posts_.end(); ++post) { |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 bool audible, | 584 bool audible, |
585 const WhispernetClient::SamplesCallback& samples_callback) { | 585 const WhispernetClient::SamplesCallback& samples_callback) { |
586 WhispernetClient* whispernet_client = delegate_->GetWhispernetClient(); | 586 WhispernetClient* whispernet_client = delegate_->GetWhispernetClient(); |
587 if (whispernet_client) { | 587 if (whispernet_client) { |
588 whispernet_client->RegisterSamplesCallback(samples_callback); | 588 whispernet_client->RegisterSamplesCallback(samples_callback); |
589 whispernet_client->EncodeToken(token, audible); | 589 whispernet_client->EncodeToken(token, audible); |
590 } | 590 } |
591 } | 591 } |
592 | 592 |
593 } // namespace copresence | 593 } // namespace copresence |
OLD | NEW |