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 "chrome/browser/extensions/api/audio_modem/audio_modem_api.h" |
| 6 |
5 #include <stdint.h> | 7 #include <stdint.h> |
6 | |
7 #include <map> | 8 #include <map> |
8 #include <string> | 9 #include <string> |
| 10 #include <utility> |
9 #include <vector> | 11 #include <vector> |
10 | 12 |
11 #include "base/base64.h" | 13 #include "base/base64.h" |
12 #include "base/bind.h" | 14 #include "base/bind.h" |
13 #include "base/guid.h" | 15 #include "base/guid.h" |
14 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
15 #include "base/logging.h" | 17 #include "base/logging.h" |
16 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
17 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
18 #include "base/timer/timer.h" | 20 #include "base/timer/timer.h" |
19 #include "chrome/browser/copresence/chrome_whispernet_client.h" | 21 #include "chrome/browser/copresence/chrome_whispernet_client.h" |
20 #include "chrome/browser/extensions/api/audio_modem/audio_modem_api.h" | |
21 #include "chrome/common/extensions/api/audio_modem.h" | 22 #include "chrome/common/extensions/api/audio_modem.h" |
22 #include "extensions/browser/event_router.h" | 23 #include "extensions/browser/event_router.h" |
23 | 24 |
24 // TODO(ckehoe): Implement transmit fail checking. | 25 // TODO(ckehoe): Implement transmit fail checking. |
25 | 26 |
26 namespace extensions { | 27 namespace extensions { |
27 | 28 |
28 using api::audio_modem::AUDIOBAND_AUDIBLE; | 29 using api::audio_modem::AUDIOBAND_AUDIBLE; |
29 using api::audio_modem::AUDIOBAND_INAUDIBLE; | 30 using api::audio_modem::AUDIOBAND_INAUDIBLE; |
30 using api::audio_modem::Audioband; | 31 using api::audio_modem::Audioband; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 AudioModemAPI::AudioModemAPI(content::BrowserContext* context) | 105 AudioModemAPI::AudioModemAPI(content::BrowserContext* context) |
105 : AudioModemAPI(context, | 106 : AudioModemAPI(context, |
106 make_scoped_ptr(new ChromeWhispernetClient(context)), | 107 make_scoped_ptr(new ChromeWhispernetClient(context)), |
107 audio_modem::Modem::Create()) {} | 108 audio_modem::Modem::Create()) {} |
108 | 109 |
109 AudioModemAPI::AudioModemAPI( | 110 AudioModemAPI::AudioModemAPI( |
110 content::BrowserContext* context, | 111 content::BrowserContext* context, |
111 scoped_ptr<audio_modem::WhispernetClient> whispernet_client, | 112 scoped_ptr<audio_modem::WhispernetClient> whispernet_client, |
112 scoped_ptr<audio_modem::Modem> modem) | 113 scoped_ptr<audio_modem::Modem> modem) |
113 : browser_context_(context), | 114 : browser_context_(context), |
114 whispernet_client_(whispernet_client.Pass()), | 115 whispernet_client_(std::move(whispernet_client)), |
115 modem_(modem.Pass()), | 116 modem_(std::move(modem)), |
116 init_failed_(false) { | 117 init_failed_(false) { |
117 // We own these objects, so these callbacks will not outlive us. | 118 // We own these objects, so these callbacks will not outlive us. |
118 whispernet_client_->Initialize( | 119 whispernet_client_->Initialize( |
119 base::Bind(&AudioModemAPI::WhispernetInitComplete, | 120 base::Bind(&AudioModemAPI::WhispernetInitComplete, |
120 base::Unretained(this))); | 121 base::Unretained(this))); |
121 modem_->Initialize(whispernet_client_.get(), | 122 modem_->Initialize(whispernet_client_.get(), |
122 base::Bind(&AudioModemAPI::TokensReceived, | 123 base::Bind(&AudioModemAPI::TokensReceived, |
123 base::Unretained(this))); | 124 base::Unretained(this))); |
124 } | 125 } |
125 | 126 |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 ExtensionFunction::ResponseAction AudioModemStopReceiveFunction::Run() { | 342 ExtensionFunction::ResponseAction AudioModemStopReceiveFunction::Run() { |
342 scoped_ptr<StopReceive::Params> params(StopReceive::Params::Create(*args_)); | 343 scoped_ptr<StopReceive::Params> params(StopReceive::Params::Create(*args_)); |
343 EXTENSION_FUNCTION_VALIDATE(params.get()); | 344 EXTENSION_FUNCTION_VALIDATE(params.get()); |
344 | 345 |
345 Status status = AudioModemAPI::GetFactoryInstance()->Get(browser_context()) | 346 Status status = AudioModemAPI::GetFactoryInstance()->Get(browser_context()) |
346 ->StopReceive(extension_id(), AudioTypeForBand(params->band)); | 347 ->StopReceive(extension_id(), AudioTypeForBand(params->band)); |
347 return RespondNow(ArgumentList(StopReceive::Results::Create(status))); | 348 return RespondNow(ArgumentList(StopReceive::Results::Create(status))); |
348 } | 349 } |
349 | 350 |
350 } // namespace extensions | 351 } // namespace extensions |
OLD | NEW |