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

Side by Side Diff: chrome/browser/extensions/api/copresence_private/copresence_private_api.cc

Issue 704923002: Add polling and audio check to copresence. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/copresence_private/copresence_private_ap i.h" 5 #include "chrome/browser/extensions/api/copresence_private/copresence_private_ap i.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 scoped_refptr<media::AudioBusRefCounted> samples = 58 scoped_refptr<media::AudioBusRefCounted> samples =
59 media::AudioBusRefCounted::Create(1, 59 media::AudioBusRefCounted::Create(1,
60 params->samples.size() / sizeof(float)); 60 params->samples.size() / sizeof(float));
61 61
62 memcpy(samples->channel(0), 62 memcpy(samples->channel(0),
63 string_as_array(&params->samples), 63 string_as_array(&params->samples),
64 params->samples.size()); 64 params->samples.size());
65 65
66 GetWhispernetClient()->GetSamplesCallback().Run( 66 GetWhispernetClient()->GetSamplesCallback().Run(
67 params->token.token,
68 params->token.audible ? copresence::AUDIBLE : copresence::INAUDIBLE, 67 params->token.audible ? copresence::AUDIBLE : copresence::INAUDIBLE,
69 samples); 68 params->token.token, samples);
70 return RespondNow(NoArguments()); 69 return RespondNow(NoArguments());
71 } 70 }
72 71
73 // CopresenceSendDetectFunction implementation: 72 // CopresenceSendDetectFunction implementation:
74 ExtensionFunction::ResponseAction CopresencePrivateSendDetectFunction::Run() { 73 ExtensionFunction::ResponseAction CopresencePrivateSendDetectFunction::Run() {
75 if (!GetWhispernetClient() || 74 if (!GetWhispernetClient() ||
76 GetWhispernetClient()->GetDetectBroadcastCallback().is_null()) { 75 GetWhispernetClient()->GetDetectBroadcastCallback().is_null()) {
77 return RespondNow(NoArguments()); 76 return RespondNow(NoArguments());
78 } 77 }
79 78
(...skipping 15 matching lines...) Expand all
95 94
96 scoped_ptr<api::copresence_private::SendInitialized::Params> params( 95 scoped_ptr<api::copresence_private::SendInitialized::Params> params(
97 api::copresence_private::SendInitialized::Params::Create(*args_)); 96 api::copresence_private::SendInitialized::Params::Create(*args_));
98 EXTENSION_FUNCTION_VALIDATE(params.get()); 97 EXTENSION_FUNCTION_VALIDATE(params.get());
99 98
100 GetWhispernetClient()->GetInitializedCallback().Run(params->success); 99 GetWhispernetClient()->GetInitializedCallback().Run(params->success);
101 return RespondNow(NoArguments()); 100 return RespondNow(NoArguments());
102 } 101 }
103 102
104 } // namespace extensions 103 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698