| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/guid.h" | 9 #include "base/guid.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 | 13 |
| 14 // TODO(ckehoe): time.h includes windows.h, which #defines DeviceCapabilities | 14 // TODO(ckehoe): time.h includes windows.h, which #defines DeviceCapabilities |
| 15 // to DeviceCapabilitiesW. This breaks the pb.h headers below. For now, | 15 // to DeviceCapabilitiesW. This breaks the pb.h headers below. For now, |
| 16 // we fix this with an #undef. | 16 // we fix this with an #undef. |
| 17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #if defined(OS_WIN) | 18 #if defined(OS_WIN) |
| 19 #undef DeviceCapabilities | 19 #undef DeviceCapabilities |
| 20 #endif | 20 #endif |
| 21 | 21 |
| 22 #include "components/audio_modem/public/audio_modem_types.h" |
| 22 #include "components/copresence/copresence_state_impl.h" | 23 #include "components/copresence/copresence_state_impl.h" |
| 23 #include "components/copresence/copresence_switches.h" | 24 #include "components/copresence/copresence_switches.h" |
| 24 #include "components/copresence/handlers/directive_handler.h" | 25 #include "components/copresence/handlers/directive_handler.h" |
| 25 #include "components/copresence/handlers/gcm_handler.h" | 26 #include "components/copresence/handlers/gcm_handler.h" |
| 26 #include "components/copresence/proto/codes.pb.h" | 27 #include "components/copresence/proto/codes.pb.h" |
| 27 #include "components/copresence/proto/data.pb.h" | 28 #include "components/copresence/proto/data.pb.h" |
| 28 #include "components/copresence/proto/rpcs.pb.h" | 29 #include "components/copresence/proto/rpcs.pb.h" |
| 29 #include "components/copresence/public/copresence_constants.h" | 30 #include "components/copresence/public/copresence_constants.h" |
| 30 #include "components/copresence/public/copresence_delegate.h" | 31 #include "components/copresence/public/copresence_delegate.h" |
| 31 #include "components/copresence/rpc/http_post.h" | 32 #include "components/copresence/rpc/http_post.h" |
| 32 #include "net/http/http_status_code.h" | 33 #include "net/http/http_status_code.h" |
| 33 | 34 |
| 34 using google::protobuf::MessageLite; | 35 using google::protobuf::MessageLite; |
| 35 | 36 |
| 37 using audio_modem::AUDIBLE; |
| 38 using audio_modem::AudioToken; |
| 39 using audio_modem::INAUDIBLE; |
| 40 |
| 36 // TODO(ckehoe): Return error messages for bad requests. | 41 // TODO(ckehoe): Return error messages for bad requests. |
| 37 | 42 |
| 38 namespace copresence { | 43 namespace copresence { |
| 39 | 44 |
| 40 const char RpcHandler::kReportRequestRpcName[] = "report"; | 45 const char RpcHandler::kReportRequestRpcName[] = "report"; |
| 41 | 46 |
| 42 namespace { | 47 namespace { |
| 43 | 48 |
| 44 const int kTokenLoggingSuffix = 5; | 49 const int kTokenLoggingSuffix = 5; |
| 45 const int kInvalidTokenExpiryTimeMs = 10 * 60 * 1000; // 10 minutes. | 50 const int kInvalidTokenExpiryTimeMs = 10 * 60 * 1000; // 10 minutes. |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 api_key, | 636 api_key, |
| 632 auth_token, | 637 auth_token, |
| 633 command_line->GetSwitchValueASCII(switches::kCopresenceTracingToken), | 638 command_line->GetSwitchValueASCII(switches::kCopresenceTracingToken), |
| 634 *request_proto); | 639 *request_proto); |
| 635 | 640 |
| 636 http_post->Start(base::Bind(callback, http_post)); | 641 http_post->Start(base::Bind(callback, http_post)); |
| 637 pending_posts_.insert(http_post); | 642 pending_posts_.insert(http_post); |
| 638 } | 643 } |
| 639 | 644 |
| 640 } // namespace copresence | 645 } // namespace copresence |
| OLD | NEW |