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

Side by Side 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: Fixing nits 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_SESSION_H_
6 #define EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_SESSION_H_
7
8 #include "base/callback.h"
9 #include "base/macros.h"
10 #include "extensions/common/api/display_source.h"
11 #include "third_party/WebKit/public/web/WebDOMMediaStreamTrack.h"
12
13 namespace extensions {
14
15 using DisplaySourceAuthInfo = api::display_source::AuthenticationInfo;
16 using DisplaySourceErrorType = api::display_source::ErrorType;
17
18 // This class represents a generic display source session interface.
19 class DisplaySourceSession {
20 public:
21 using SinkIdCallback = base::Callback<void(int sink_id)>;
22 using ErrorCallback =
23 base::Callback<void(int sink_id,
24 DisplaySourceErrorType error_type,
25 const std::string& error_description)>;
26
27 // State flow is ether:
28 // 'Idle' -> 'Establishing' -> 'Established' -> 'Terminating' -> 'Idle'
29 // (terminated by Terminate() call)
30 // or
31 // 'Idle' -> 'Establishing' -> 'Established' -> 'Idle'
32 // (terminated from sink device or due to an error)
33 enum State {
34 Idle,
35 Establishing,
36 Established,
37 Terminating
38 };
39
40 virtual ~DisplaySourceSession();
41
42 // Starts the session.
43 // The session state should be set to 'Establishing' immediately after this
44 // method is called.
45 virtual void Start() = 0;
46
47 // Terminates the session.
48 // The session state should be set to 'Terminating' immediately after this
49 // method is called.
50 virtual void Terminate() = 0;
51
52 State state() const { return state_; }
53
54 // Sets the callbacks invoked to inform about the session's state changes.
55 // It is required to set the callbacks before the session is started.
56 // |started_callback| : Called when the session was actually started (state
57 // should be set to 'Established')
58 // |terminated_callback| : Called when the session was actually started (state
59 // should be set to 'Idle')
60 // |error_callback| : Called if a fatal error has occured and the session
61 // either cannot be started (if was invoked in
62 // 'Establishing' state) or will be terminated soon for
63 // emergency reasons (if was invoked in 'Established'
64 // state).
65 void SetCallbacks(const SinkIdCallback& started_callback,
66 const SinkIdCallback& terminated_callback,
67 const ErrorCallback& error_callback);
68
69 protected:
70 DisplaySourceSession();
71
72 State state_;
73 SinkIdCallback started_callback_;
74 SinkIdCallback terminated_callback_;
75 ErrorCallback error_callback_;
76
77 private:
78 DISALLOW_COPY_AND_ASSIGN(DisplaySourceSession);
79 };
80
81 class DisplaySourceSessionFactory {
82 public:
83 static scoped_ptr<DisplaySourceSession> CreateSession(
84 int sink_id,
85 const blink::WebMediaStreamTrack& video_track,
86 const blink::WebMediaStreamTrack& audio_track,
87 scoped_ptr<DisplaySourceAuthInfo> auth_info);
88 private:
89 DISALLOW_COPY_AND_ASSIGN(DisplaySourceSessionFactory);
90 };
91
92 } // namespace extensions
93
94 #endif // EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_SESSION_H_
OLDNEW
« no previous file with comments | « extensions/renderer/api/display_source/OWNERS ('k') | extensions/renderer/api/display_source/display_source_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698