OLD | NEW |
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 Loading... |
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 CallSessionStartedCallback( |
| 34 int sink_id, |
| 35 const std::string& error_message = std::string()); |
| 36 void CallSessionTerminatedCallback( |
| 37 int sink_id, |
| 38 const std::string& error_message = std::string()); |
| 39 void CallCompletionCallback(const v8::Global<v8::Function>& callback, |
| 40 const std::string& error_message); |
| 41 // Dispatch events |
33 void DispatchSessionStarted(int sink_id) const; | 42 void DispatchSessionStarted(int sink_id) const; |
34 void DispatchSessionTerminated(int sink_id) const; | 43 void DispatchSessionTerminated(int sink_id) const; |
35 void DispatchSessionError(int sink_id, | 44 void DispatchSessionError(int sink_id, |
36 DisplaySourceErrorType type, | 45 DisplaySourceErrorType type, |
37 const std::string& message) const; | 46 const std::string& message) const; |
38 | 47 |
39 // DisplaySession callbacks. | 48 // DisplaySession callbacks. |
40 void OnSessionStarted(int sink_id); | 49 void OnSessionStarted(int sink_id); |
41 void OnSessionTerminated(int sink_id); | 50 void OnSessionTerminated(int sink_id); |
42 void OnSessionError(int sink_id, | 51 void OnSessionError(int sink_id, |
43 DisplaySourceErrorType type, | 52 DisplaySourceErrorType type, |
44 const std::string& message); | 53 const std::string& message); |
45 | 54 |
46 DisplaySourceSession* GetDisplaySession(int sink_id) const; | 55 DisplaySourceSession* GetDisplaySession(int sink_id) const; |
47 | 56 |
48 std::map<int, scoped_ptr<DisplaySourceSession>> session_map_; | 57 std::map<int, scoped_ptr<DisplaySourceSession>> session_map_; |
| 58 std::map<int, v8::Global<v8::Function>> session_started_cb_map_; |
| 59 std::map<int, v8::Global<v8::Function>> session_finished_cb_map_; |
49 base::WeakPtrFactory<DisplaySourceCustomBindings> weak_factory_; | 60 base::WeakPtrFactory<DisplaySourceCustomBindings> weak_factory_; |
50 | 61 |
51 DISALLOW_COPY_AND_ASSIGN(DisplaySourceCustomBindings); | 62 DISALLOW_COPY_AND_ASSIGN(DisplaySourceCustomBindings); |
52 }; | 63 }; |
53 | 64 |
54 } // extensions | 65 } // extensions |
55 | 66 |
56 #endif // EXTENSIONS_RENDERER_DISPLAY_SOURCE_CUSTOM_BINDINGS_H_ | 67 #endif // EXTENSIONS_RENDERER_DISPLAY_SOURCE_CUSTOM_BINDINGS_H_ |
OLD | NEW |