OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <map> | 5 #include <map> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/guid.h" | 11 #include "base/guid.h" |
12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/stl_util.h" | |
16 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
17 #include "base/timer/timer.h" | 16 #include "base/timer/timer.h" |
18 #include "chrome/browser/copresence/chrome_whispernet_client.h" | 17 #include "chrome/browser/copresence/chrome_whispernet_client.h" |
19 #include "chrome/browser/extensions/api/audio_modem/audio_modem_api.h" | 18 #include "chrome/browser/extensions/api/audio_modem/audio_modem_api.h" |
20 #include "chrome/common/extensions/api/audio_modem.h" | 19 #include "chrome/common/extensions/api/audio_modem.h" |
21 #include "extensions/browser/event_router.h" | 20 #include "extensions/browser/event_router.h" |
22 | 21 |
23 // TODO(ckehoe): Implement transmit fail checking. | 22 // TODO(ckehoe): Implement transmit fail checking. |
24 | 23 |
25 namespace extensions { | 24 namespace extensions { |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 kInitFailedError)); | 271 kInitFailedError)); |
273 } | 272 } |
274 | 273 |
275 // Check the token length. | 274 // Check the token length. |
276 int token_length = params->params.encoding.token_length; | 275 int token_length = params->params.encoding.token_length; |
277 if (token_length <= 0) { | 276 if (token_length <= 0) { |
278 return RespondNow(ErrorWithArguments( | 277 return RespondNow(ErrorWithArguments( |
279 Transmit::Results::Create(STATUS_INVALIDREQUEST), | 278 Transmit::Results::Create(STATUS_INVALIDREQUEST), |
280 kInvalidTokenLengthError)); | 279 kInvalidTokenLengthError)); |
281 } | 280 } |
282 const char* token = vector_as_array(¶ms->token); | 281 const char* token = params->token.data(); |
283 std::string token_str(token, params->token.size()); | 282 std::string token_str(token, params->token.size()); |
284 if (static_cast<int>(token_str.size()) != token_length) { | 283 if (static_cast<int>(token_str.size()) != token_length) { |
285 return RespondNow(ErrorWithArguments( | 284 return RespondNow(ErrorWithArguments( |
286 Transmit::Results::Create(STATUS_INVALIDREQUEST), | 285 Transmit::Results::Create(STATUS_INVALIDREQUEST), |
287 kIncorrectTokenLengthError)); | 286 kIncorrectTokenLengthError)); |
288 } | 287 } |
289 | 288 |
290 // Check the timeout. | 289 // Check the timeout. |
291 int64_t timeout_millis = params->params.timeout_millis; | 290 int64_t timeout_millis = params->params.timeout_millis; |
292 if (timeout_millis <= 0) { | 291 if (timeout_millis <= 0) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 ExtensionFunction::ResponseAction AudioModemStopReceiveFunction::Run() { | 339 ExtensionFunction::ResponseAction AudioModemStopReceiveFunction::Run() { |
341 scoped_ptr<StopReceive::Params> params(StopReceive::Params::Create(*args_)); | 340 scoped_ptr<StopReceive::Params> params(StopReceive::Params::Create(*args_)); |
342 EXTENSION_FUNCTION_VALIDATE(params.get()); | 341 EXTENSION_FUNCTION_VALIDATE(params.get()); |
343 | 342 |
344 Status status = AudioModemAPI::GetFactoryInstance()->Get(browser_context()) | 343 Status status = AudioModemAPI::GetFactoryInstance()->Get(browser_context()) |
345 ->StopReceive(extension_id(), AudioTypeForBand(params->band)); | 344 ->StopReceive(extension_id(), AudioTypeForBand(params->band)); |
346 return RespondNow(ArgumentList(StopReceive::Results::Create(status))); | 345 return RespondNow(ArgumentList(StopReceive::Results::Create(status))); |
347 } | 346 } |
348 | 347 |
349 } // namespace extensions | 348 } // namespace extensions |
OLD | NEW |