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

Unified Diff: components/copresence/public/whispernet_client.h

Issue 438513002: Add the whispernet proxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: components/copresence/public/whispernet_client.h
diff --git a/components/copresence/public/whispernet_client.h b/components/copresence/public/whispernet_client.h
new file mode 100644
index 0000000000000000000000000000000000000000..afec22b2f4684d2a67fb526548574e2c78b9c2d9
--- /dev/null
+++ b/components/copresence/public/whispernet_client.h
@@ -0,0 +1,70 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_COPRESENCE_INTERFACE_WHISPERNET_CLIENT_H_
+#define COMPONENTS_COPRESENCE_INTERFACE_WHISPERNET_CLIENT_H_
+
+#include <string>
+#include <vector>
+
+#include "base/callback.h"
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
xiyuan 2014/07/31 19:22:23 not used?
rkc 2014/07/31 23:12:54 Done.
+
+namespace media {
+class AudioBusRefCounted;
+}
+
+namespace copresence {
+
+// The interface that the whispernet client needs to implement. These methods
+// provide us the ability to use the audio medium in copresence. Currently since
+// the only medium that copresence uses is audio, the implementation of this
+// interface is required.
+class WhispernetClient {
+ public:
+ // Generic callback to indicate a boolean success or failure.
+ typedef base::Callback<void(bool)> SuccessCallback;
+ // Callback that returns detected tokens.
+ typedef base::Callback<void(const std::vector<std::string>&)> TokensCallback;
+ // Callback that returns encoded samples for a given token.
+ typedef base::Callback<
+ void(const std::string&, const scoped_refptr<media::AudioBusRefCounted>&)>
xiyuan 2014/07/31 19:22:23 nit: #include "base/memory/ref_counted.h"
rkc 2014/07/31 23:12:53 Done.
+ SamplesCallback;
+
+ // Initialize the whispernet client and call the callback when done. The
+ // parameter indicates whether we succeeded or failed.
+ virtual void Initialize(const SuccessCallback& init_callback) = 0;
+ // Copresence will call this before making any calls to its destructors.
+ virtual void Shutdown() = 0;
+
+ // Fires an event to request a token encode.
+ virtual void EncodeToken(const std::string& token) = 0;
+ // Fires an event to request a decode for the given samples.
+ virtual void DecodeSamples(const std::string& samples) = 0;
+ // Fires an event to request detection of a whispernet broadcast.
+ virtual void DetectBroadcast() = 0;
+
+ // Callback registreation methods. These are the callbacks that will be
+ // registered by Copresence to receive data.
+ virtual void RegisterTokensCallback(
+ const TokensCallback& tokens_callback) = 0;
+ virtual void RegisterSamplesCallback(
+ const SamplesCallback& samples_callback) = 0;
+ virtual void RegisterDetectBroadcastCallback(
+ const SuccessCallback& db_callback) = 0;
+
+ // Don't cache these callbacks, as they may become invalid at any time.
+ // Always invoke callbacks directly through these accessors.
+ virtual TokensCallback GetTokensCallback() = 0;
+ virtual SamplesCallback GetSamplesCallback() = 0;
+ virtual SuccessCallback GetDetectBroadcastCallback() = 0;
+ virtual SuccessCallback GetInitializedCallback() = 0;
+
+ virtual ~WhispernetClient() {};
+};
+
+} // namespace copresence
+
+#endif // COMPONENTS_COPRESENCE_INTERFACE_WHISPERNET_CLIENT_H_

Powered by Google App Engine
This is Rietveld 408576698