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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 transmitters_[audio_type] = app_id; | 137 transmitters_[audio_type] = app_id; |
138 else if (transmitters_[audio_type] != app_id) | 138 else if (transmitters_[audio_type] != app_id) |
139 return STATUS_INUSE; | 139 return STATUS_INUSE; |
140 | 140 |
141 DVLOG(3) << "Starting transmit for app " << app_id; | 141 DVLOG(3) << "Starting transmit for app " << app_id; |
142 | 142 |
143 std::string encoded_token; | 143 std::string encoded_token; |
144 base::Base64Encode(token, &encoded_token); | 144 base::Base64Encode(token, &encoded_token); |
145 base::RemoveChars(encoded_token, "=", &encoded_token); | 145 base::RemoveChars(encoded_token, "=", &encoded_token); |
146 | 146 |
| 147 modem_->SetTokenParams(audio_type, TokenParamsForEncoding(params.encoding)); |
147 modem_->SetToken(audio_type, encoded_token); | 148 modem_->SetToken(audio_type, encoded_token); |
148 modem_->SetTokenParams(audio_type, TokenParamsForEncoding(params.encoding)); | |
149 modem_->StartPlaying(audio_type); | 149 modem_->StartPlaying(audio_type); |
150 | 150 |
151 transmit_timers_[audio_type].Start( | 151 transmit_timers_[audio_type].Start( |
152 FROM_HERE, | 152 FROM_HERE, |
153 base::TimeDelta::FromMilliseconds(params.timeout_millis), | 153 base::TimeDelta::FromMilliseconds(params.timeout_millis), |
154 base::Bind(base::IgnoreResult(&AudioModemAPI::StopTransmit), | 154 base::Bind(base::IgnoreResult(&AudioModemAPI::StopTransmit), |
155 base::Unretained(this), | 155 base::Unretained(this), |
156 app_id, | 156 app_id, |
157 audio_type)); | 157 audio_type)); |
158 return STATUS_SUCCESS; | 158 return STATUS_SUCCESS; |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 ExtensionFunction::ResponseAction AudioModemStopReceiveFunction::Run() { | 339 ExtensionFunction::ResponseAction AudioModemStopReceiveFunction::Run() { |
340 scoped_ptr<StopReceive::Params> params(StopReceive::Params::Create(*args_)); | 340 scoped_ptr<StopReceive::Params> params(StopReceive::Params::Create(*args_)); |
341 EXTENSION_FUNCTION_VALIDATE(params.get()); | 341 EXTENSION_FUNCTION_VALIDATE(params.get()); |
342 | 342 |
343 Status status = AudioModemAPI::GetFactoryInstance()->Get(browser_context()) | 343 Status status = AudioModemAPI::GetFactoryInstance()->Get(browser_context()) |
344 ->StopReceive(extension_id(), AudioTypeForBand(params->band)); | 344 ->StopReceive(extension_id(), AudioTypeForBand(params->band)); |
345 return RespondNow(ArgumentList(StopReceive::Results::Create(status))); | 345 return RespondNow(ArgumentList(StopReceive::Results::Create(status))); |
346 } | 346 } |
347 | 347 |
348 } // namespace extensions | 348 } // namespace extensions |
OLD | NEW |