Chromium Code Reviews| 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 | |
| 15 // TODO(ckehoe): time.h includes windows.h, which #defines DeviceCapabilities | |
| 16 // to DeviceCapabilitiesW. This breaks the pb.h headers below. For now, | |
| 17 // we fix this with an #undef. | |
| 14 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #if defined(OS_WIN) | |
|
Charlie
2014/08/26 16:37:50
Maybe this should say #if defined(DeviceCapabiliti
rkc
2014/08/26 16:45:14
This seems more apt; self-documents to be a Window
| |
| 20 #undef DeviceCapabilities | |
| 21 #endif | |
| 22 | |
| 15 #include "components/copresence/copresence_switches.h" | 23 #include "components/copresence/copresence_switches.h" |
| 16 #include "components/copresence/handlers/directive_handler.h" | 24 #include "components/copresence/handlers/directive_handler.h" |
| 17 #include "components/copresence/proto/codes.pb.h" | 25 #include "components/copresence/proto/codes.pb.h" |
| 18 #include "components/copresence/proto/data.pb.h" | 26 #include "components/copresence/proto/data.pb.h" |
| 19 #include "components/copresence/proto/rpcs.pb.h" | 27 #include "components/copresence/proto/rpcs.pb.h" |
| 20 #include "components/copresence/public/copresence_delegate.h" | 28 #include "components/copresence/public/copresence_delegate.h" |
| 21 #include "net/http/http_status_code.h" | 29 #include "net/http/http_status_code.h" |
| 22 | 30 |
| 23 // TODO(ckehoe): Return error messages for bad requests. | 31 // TODO(ckehoe): Return error messages for bad requests. |
| 24 | 32 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 return true; | 163 return true; |
| 156 } | 164 } |
| 157 } | 165 } |
| 158 } | 166 } |
| 159 return false; | 167 return false; |
| 160 } | 168 } |
| 161 | 169 |
| 162 scoped_ptr<DeviceState> GetDeviceCapabilities(const ReportRequest& request) { | 170 scoped_ptr<DeviceState> GetDeviceCapabilities(const ReportRequest& request) { |
| 163 scoped_ptr<DeviceState> state(new DeviceState); | 171 scoped_ptr<DeviceState> state(new DeviceState); |
| 164 | 172 |
| 165 // TODO(ckehoe): Currently this code causes a linker error on Windows. | |
| 166 #ifndef OS_WIN | |
| 167 TokenTechnology* token_technology = | 173 TokenTechnology* token_technology = |
| 168 state->mutable_capabilities()->add_token_technology(); | 174 state->mutable_capabilities()->add_token_technology(); |
| 169 token_technology->set_medium(AUDIO_ULTRASOUND_PASSBAND); | 175 token_technology->set_medium(AUDIO_ULTRASOUND_PASSBAND); |
| 170 if (ExtractIsAudibleStrategy(request)) | 176 if (ExtractIsAudibleStrategy(request)) |
| 171 token_technology->set_medium(AUDIO_AUDIBLE_DTMF); | 177 token_technology->set_medium(AUDIO_AUDIBLE_DTMF); |
| 172 | 178 |
| 173 BroadcastScanConfiguration config = | 179 BroadcastScanConfiguration config = |
| 174 ExtractTokenExchangeStrategy(request); | 180 ExtractTokenExchangeStrategy(request); |
| 175 if (config == BROADCAST_ONLY || config == BROADCAST_AND_SCAN) | 181 if (config == BROADCAST_ONLY || config == BROADCAST_AND_SCAN) |
| 176 token_technology->add_instruction_type(TRANSMIT); | 182 token_technology->add_instruction_type(TRANSMIT); |
| 177 if (config == SCAN_ONLY || config == BROADCAST_AND_SCAN) | 183 if (config == SCAN_ONLY || config == BROADCAST_AND_SCAN) |
| 178 token_technology->add_instruction_type(RECEIVE); | 184 token_technology->add_instruction_type(RECEIVE); |
| 179 #endif | |
| 180 | 185 |
| 181 return state.Pass(); | 186 return state.Pass(); |
| 182 } | 187 } |
| 183 | 188 |
| 184 // TODO(ckehoe): We're keeping this code in a separate function for now | 189 // TODO(ckehoe): We're keeping this code in a separate function for now |
| 185 // because we get a version string from Chrome, but the proto expects | 190 // because we get a version string from Chrome, but the proto expects |
| 186 // an int64 version. We should probably change the version proto | 191 // an int64 version. We should probably change the version proto |
| 187 // to handle a more detailed version. | 192 // to handle a more detailed version. |
| 188 ClientVersion* CreateVersion(const std::string& client, | 193 ClientVersion* CreateVersion(const std::string& client, |
| 189 const std::string& version_name) { | 194 const std::string& version_name) { |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 568 bool audible, | 573 bool audible, |
| 569 const WhispernetClient::SamplesCallback& samples_callback) { | 574 const WhispernetClient::SamplesCallback& samples_callback) { |
| 570 WhispernetClient* whispernet_client = delegate_->GetWhispernetClient(); | 575 WhispernetClient* whispernet_client = delegate_->GetWhispernetClient(); |
| 571 if (whispernet_client) { | 576 if (whispernet_client) { |
| 572 whispernet_client->RegisterSamplesCallback(samples_callback); | 577 whispernet_client->RegisterSamplesCallback(samples_callback); |
| 573 whispernet_client->EncodeToken(token, audible); | 578 whispernet_client->EncodeToken(token, audible); |
| 574 } | 579 } |
| 575 } | 580 } |
| 576 | 581 |
| 577 } // namespace copresence | 582 } // namespace copresence |
| OLD | NEW |