Chromium Code Reviews| Index: chrome/browser/copresence/chrome_whispernet_client.cc |
| diff --git a/chrome/browser/copresence/chrome_whispernet_client.cc b/chrome/browser/copresence/chrome_whispernet_client.cc |
| index 6cffe0383343a1b5597b2913cc5b806369d5e83c..8150bdb274189c58c2efe617142ac0e0d4ed0791 100644 |
| --- a/chrome/browser/copresence/chrome_whispernet_client.cc |
| +++ b/chrome/browser/copresence/chrome_whispernet_client.cc |
| @@ -63,7 +63,7 @@ void ChromeWhispernetClient::Shutdown() { |
| // Fire an event to request a token encode. |
| void ChromeWhispernetClient::EncodeToken(const std::string& token, |
| - bool audible) { |
| + copresence::AudioType type) { |
| DCHECK(extension_loaded_); |
| DCHECK(browser_context_); |
| DCHECK(extensions::EventRouter::Get(browser_context_)); |
| @@ -71,7 +71,7 @@ void ChromeWhispernetClient::EncodeToken(const std::string& token, |
| scoped_ptr<extensions::Event> event(new extensions::Event( |
| extensions::api::copresence_private::OnEncodeTokenRequest::kEventName, |
| extensions::api::copresence_private::OnEncodeTokenRequest::Create( |
| - token, audible), |
| + token, type == copresence::AUDIBLE), |
| browser_context_)); |
| extensions::EventRouter::Get(browser_context_) |
| @@ -79,15 +79,37 @@ void ChromeWhispernetClient::EncodeToken(const std::string& token, |
| } |
| // Fire an event to request a decode for the given samples. |
| -void ChromeWhispernetClient::DecodeSamples(const std::string& samples) { |
| +void ChromeWhispernetClient::DecodeSamples(copresence::AudioType type, |
| + const std::string& samples) { |
| DCHECK(extension_loaded_); |
| DCHECK(browser_context_); |
| DCHECK(extensions::EventRouter::Get(browser_context_)); |
| + extensions::api::copresence_private::DecodeRequestType request_type; |
| + |
| + switch (type) { |
|
Daniel Erat
2014/10/17 22:25:59
you could get compile-time checking that all enum
rkc
2014/10/18 00:21:54
Code removed with Patch 3.
|
| + case copresence::AUDIBLE: |
| + request_type = |
| + extensions::api::copresence_private::DECODE_REQUEST_TYPE_AUDIBLE; |
| + break; |
| + case copresence::INAUDIBLE: |
| + request_type = |
| + extensions::api::copresence_private::DECODE_REQUEST_TYPE_INAUDIBLE; |
| + break; |
| + case copresence::BOTH: |
| + request_type = |
| + extensions::api::copresence_private::DECODE_REQUEST_TYPE_BOTH; |
| + break; |
| + default: |
| + request_type = |
| + extensions::api::copresence_private::DECODE_REQUEST_TYPE_NONE; |
| + LOG(ERROR) << "Unknown decode request type received: " << type; |
| + } |
| + |
| scoped_ptr<extensions::Event> event(new extensions::Event( |
| extensions::api::copresence_private::OnDecodeSamplesRequest::kEventName, |
| extensions::api::copresence_private::OnDecodeSamplesRequest::Create( |
| - samples), |
| + request_type, samples), |
| browser_context_)); |
| extensions::EventRouter::Get(browser_context_) |