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" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 171 |
172 void AudioModemAPI::StartReceive(const std::string& app_id, | 172 void AudioModemAPI::StartReceive(const std::string& app_id, |
173 const RequestParams& params) { | 173 const RequestParams& params) { |
174 DVLOG(3) << "Starting receive for app " << app_id; | 174 DVLOG(3) << "Starting receive for app " << app_id; |
175 | 175 |
176 AudioType audio_type = AudioTypeForBand(params.band); | 176 AudioType audio_type = AudioTypeForBand(params.band); |
177 modem_->SetTokenParams(audio_type, TokenParamsForEncoding(params.encoding)); | 177 modem_->SetTokenParams(audio_type, TokenParamsForEncoding(params.encoding)); |
178 modem_->StartRecording(audio_type); | 178 modem_->StartRecording(audio_type); |
179 | 179 |
180 if (receive_timers_[audio_type].count(app_id) == 0) | 180 if (receive_timers_[audio_type].count(app_id) == 0) |
181 receive_timers_[audio_type][app_id] = new base::OneShotTimer<AudioModemAPI>; | 181 receive_timers_[audio_type][app_id] = new base::OneShotTimer; |
182 DCHECK(receive_timers_[audio_type][app_id]); | 182 DCHECK(receive_timers_[audio_type][app_id]); |
183 receive_timers_[audio_type][app_id]->Start( | 183 receive_timers_[audio_type][app_id]->Start( |
184 FROM_HERE, | 184 FROM_HERE, |
185 base::TimeDelta::FromMilliseconds(params.timeout_millis), | 185 base::TimeDelta::FromMilliseconds(params.timeout_millis), |
186 base::Bind(base::IgnoreResult(&AudioModemAPI::StopReceive), | 186 base::Bind(base::IgnoreResult(&AudioModemAPI::StopReceive), |
187 base::Unretained(this), | 187 base::Unretained(this), |
188 app_id, | 188 app_id, |
189 audio_type)); | 189 audio_type)); |
190 } | 190 } |
191 | 191 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 ExtensionFunction::ResponseAction AudioModemStopReceiveFunction::Run() { | 340 ExtensionFunction::ResponseAction AudioModemStopReceiveFunction::Run() { |
341 scoped_ptr<StopReceive::Params> params(StopReceive::Params::Create(*args_)); | 341 scoped_ptr<StopReceive::Params> params(StopReceive::Params::Create(*args_)); |
342 EXTENSION_FUNCTION_VALIDATE(params.get()); | 342 EXTENSION_FUNCTION_VALIDATE(params.get()); |
343 | 343 |
344 Status status = AudioModemAPI::GetFactoryInstance()->Get(browser_context()) | 344 Status status = AudioModemAPI::GetFactoryInstance()->Get(browser_context()) |
345 ->StopReceive(extension_id(), AudioTypeForBand(params->band)); | 345 ->StopReceive(extension_id(), AudioTypeForBand(params->band)); |
346 return RespondNow(ArgumentList(StopReceive::Results::Create(status))); | 346 return RespondNow(ArgumentList(StopReceive::Results::Create(status))); |
347 } | 347 } |
348 | 348 |
349 } // namespace extensions | 349 } // namespace extensions |
OLD | NEW |