Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Side by Side Diff: chrome/browser/extensions/api/audio_modem/audio_modem_api.cc

Issue 1355063004: Template methods on Timer classes instead of the classes themselves. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: timer: fixcaller Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/audio_modem/audio_modem_api.h ('k') | chrome/browser/extensions/api/dial/dial_registry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698