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

Side by Side Diff: extensions/renderer/display_source_custom_bindings.h

Issue 1674583002: [chrome.displaySource] Session notification improvements (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Init sCallId Created 4 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 #ifndef EXTENSIONS_RENDERER_DISPLAY_SOURCE_CUSTOM_BINDINGS_H_ 5 #ifndef EXTENSIONS_RENDERER_DISPLAY_SOURCE_CUSTOM_BINDINGS_H_
6 #define EXTENSIONS_RENDERER_DISPLAY_SOURCE_CUSTOM_BINDINGS_H_ 6 #define EXTENSIONS_RENDERER_DISPLAY_SOURCE_CUSTOM_BINDINGS_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "extensions/common/api/display_source.h" 9 #include "extensions/common/api/display_source.h"
10 #include "extensions/renderer/api/display_source/display_source_session.h" 10 #include "extensions/renderer/api/display_source/display_source_session.h"
(...skipping 11 matching lines...) Expand all
22 ~DisplaySourceCustomBindings() override; 22 ~DisplaySourceCustomBindings() override;
23 23
24 private: 24 private:
25 // ObjectBackedNativeHandler override. 25 // ObjectBackedNativeHandler override.
26 void Invalidate() override; 26 void Invalidate() override;
27 27
28 void StartSession( 28 void StartSession(
29 const v8::FunctionCallbackInfo<v8::Value>& args); 29 const v8::FunctionCallbackInfo<v8::Value>& args);
30 void TerminateSession( 30 void TerminateSession(
31 const v8::FunctionCallbackInfo<v8::Value>& args); 31 const v8::FunctionCallbackInfo<v8::Value>& args);
32 32 // Call completion callbacks.
33 void DispatchSessionStarted(int sink_id) const; 33 enum CallbackType { kStarted, kTerminated };
34 void CallCompletionCallback(int sink_id,
35 CallbackType type,
36 const std::string& error_message = "");
37 // Dispatch events
34 void DispatchSessionTerminated(int sink_id) const; 38 void DispatchSessionTerminated(int sink_id) const;
35 void DispatchSessionError(int sink_id, 39 void DispatchSessionError(int sink_id,
36 DisplaySourceErrorType type, 40 DisplaySourceErrorType type,
37 const std::string& message) const; 41 const std::string& message) const;
38 42
39 // DisplaySession callbacks. 43 // DisplaySession callbacks.
40 void OnSessionStarted(int sink_id); 44 void OnSessionStarted(int sink_id);
41 void OnSessionTerminated(int sink_id); 45 void OnSessionTerminated(int sink_id);
42 void OnSessionError(int sink_id, 46 void OnSessionError(int sink_id,
43 DisplaySourceErrorType type, 47 DisplaySourceErrorType type,
44 const std::string& message); 48 const std::string& message);
45 49
46 DisplaySourceSession* GetDisplaySession(int sink_id) const; 50 DisplaySourceSession* GetDisplaySession(int sink_id) const;
47 51
48 std::map<int, scoped_ptr<DisplaySourceSession>> session_map_; 52 std::map<int, scoped_ptr<DisplaySourceSession>> session_map_;
53 // Data of a call completion callback.
54 struct CallbackInfo {
55 CallbackType type;
56 int sink_id;
57 int call_id; // Each call has a unique Id.
58 };
59
60 CallbackInfo GetCallbackInfo(CallbackType type, int sink_id) const;
61
62 std::vector<CallbackInfo> callbacks_;
49 base::WeakPtrFactory<DisplaySourceCustomBindings> weak_factory_; 63 base::WeakPtrFactory<DisplaySourceCustomBindings> weak_factory_;
50 64
51 DISALLOW_COPY_AND_ASSIGN(DisplaySourceCustomBindings); 65 DISALLOW_COPY_AND_ASSIGN(DisplaySourceCustomBindings);
52 }; 66 };
53 67
54 } // extensions 68 } // extensions
55 69
56 #endif // EXTENSIONS_RENDERER_DISPLAY_SOURCE_CUSTOM_BINDINGS_H_ 70 #endif // EXTENSIONS_RENDERER_DISPLAY_SOURCE_CUSTOM_BINDINGS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698