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

Unified Diff: extensions/renderer/api/display_source/display_source_session.h

Issue 1471243002: chrome.displaySource custom bindings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Report errors via 'chrome.runtime.lastError' Created 5 years 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: extensions/renderer/api/display_source/display_source_session.h
diff --git a/extensions/renderer/api/display_source/display_source_session.h b/extensions/renderer/api/display_source/display_source_session.h
new file mode 100644
index 0000000000000000000000000000000000000000..e3f7ffcc77878eb60b84a355a960981bb9dd6f39
--- /dev/null
+++ b/extensions/renderer/api/display_source/display_source_session.h
@@ -0,0 +1,91 @@
+// Copyright 2015 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 EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_SESSION_H_
+#define EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_SESSION_H_
+
+#include "base/callback.h"
+#include "base/macros.h"
+#include "extensions/common/api/display_source.h"
+#include "third_party/WebKit/public/web/WebDOMMediaStreamTrack.h"
+
+namespace extensions {
+
+using DisplaySourceAuthInfo = api::display_source::AuthenticationInfo;
+using DisplaySourceErrorType = api::display_source::ErrorType;
+
+// This class represents a generic display source session interface.
+class DisplaySourceSession {
+ public:
+ using SinkIdCallback = base::Callback<void(int)>;
+ using ErrorCallback =
+ base::Callback<void(int, DisplaySourceErrorType, const std::string&)>;
asargent_no_longer_on_chrome 2015/12/07 21:47:49 nit: please add comments or variable names so that
Mikhail 2015/12/08 07:44:43 Done.
+
+ // State flow is ether:
+ // 'Idle' -> 'Establishing' -> 'Established' -> 'Terminating' -> 'Idle'
+ // (terminated by Terminate() call)
+ // or
+ // 'Idle' -> 'Establishing' -> 'Established' -> 'Idle'
+ // (terminated from sink device or due to an error)
+ enum State {
+ Idle,
+ Establishing,
+ Established,
+ Terminating
+ };
+
+ virtual ~DisplaySourceSession();
+
+ // Starts the session.
+ // The session state should be set to 'Establishing' immediately after this
+ // method is called.
+ virtual void Start() = 0;
+
+ // Terminates the session.
+ // The session state should be set to 'Terminating' immediately after this
+ // method is called.
+ virtual void Terminate() = 0;
+
+ State state() const { return state_; }
+
+ // Sets the callbacks invoked to inform about the session's state changes
asargent_no_longer_on_chrome 2015/12/07 21:47:49 suggestion: It might be helpful to document somewh
Mikhail 2015/12/08 07:44:42 Done.
+ // |started_callback| : Called when the session was actually started (state
+ // should be set to 'Established')
+ // |terminated_callback| : Called when the session was actually started (state
+ // should be set to 'Idle')
+ // |error_callback| : Called if a fatal error has occured and the session
+ // either cannot be started (if was invoked in
+ // 'Establishing' state) or will be terminated soon for
+ // emergency reasons (if was invoked in 'Established'
+ // state).
+ void SetCallbacks(const SinkIdCallback& started_callback,
+ const SinkIdCallback& terminated_callback,
+ const ErrorCallback& error_callback);
+
+ protected:
+ DisplaySourceSession();
+
+ State state_;
+ SinkIdCallback started_callback_;
+ SinkIdCallback terminated_callback_;
+ ErrorCallback error_callback_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DisplaySourceSession);
+};
+
+class DisplaySourceSessionFactory {
+ public:
+ static scoped_ptr<DisplaySourceSession> CreateSession(
+ int sink_id,
+ const blink::WebMediaStreamTrack& video_track,
+ const blink::WebMediaStreamTrack& audio_track,
+ scoped_ptr<DisplaySourceAuthInfo> auth_info);
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DisplaySourceSessionFactory);
+};
+
+} // namespace extensions
+
+#endif // EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_SESSION_H_

Powered by Google App Engine
This is Rietveld 408576698