| 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 12 matching lines...) Expand all Loading... |
| 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 // Call completion callbacks. | 32 // Call completion callbacks. |
| 33 enum CallbackType { kStarted, kTerminated }; | 33 void OnCallCompleted(int call_id, |
| 34 void CallCompletionCallback(int sink_id, | 34 bool success, |
| 35 CallbackType type, | 35 const std::string& error_message); |
| 36 const std::string& error_message = ""); | 36 void OnSessionStarted(int sink_id, |
| 37 int call_id, |
| 38 bool success, |
| 39 const std::string& error_message); |
| 37 // Dispatch events | 40 // Dispatch events |
| 38 void DispatchSessionTerminated(int sink_id) const; | 41 void DispatchSessionTerminated(int sink_id) const; |
| 39 void DispatchSessionError(int sink_id, | 42 void DispatchSessionError(int sink_id, |
| 40 DisplaySourceErrorType type, | 43 DisplaySourceErrorType type, |
| 41 const std::string& message) const; | 44 const std::string& message) const; |
| 42 | 45 |
| 43 // DisplaySession callbacks. | 46 // DisplaySession notification callbacks. |
| 44 void OnSessionStarted(int sink_id); | |
| 45 void OnSessionTerminated(int sink_id); | 47 void OnSessionTerminated(int sink_id); |
| 46 void OnSessionError(int sink_id, | 48 void OnSessionError(int sink_id, |
| 47 DisplaySourceErrorType type, | 49 DisplaySourceErrorType type, |
| 48 const std::string& message); | 50 const std::string& message); |
| 49 | 51 |
| 50 DisplaySourceSession* GetDisplaySession(int sink_id) const; | 52 DisplaySourceSession* GetDisplaySession(int sink_id) const; |
| 51 | 53 |
| 52 std::map<int, scoped_ptr<DisplaySourceSession>> session_map_; | 54 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_; | |
| 63 base::WeakPtrFactory<DisplaySourceCustomBindings> weak_factory_; | 55 base::WeakPtrFactory<DisplaySourceCustomBindings> weak_factory_; |
| 64 | 56 |
| 65 DISALLOW_COPY_AND_ASSIGN(DisplaySourceCustomBindings); | 57 DISALLOW_COPY_AND_ASSIGN(DisplaySourceCustomBindings); |
| 66 }; | 58 }; |
| 67 | 59 |
| 68 } // extensions | 60 } // extensions |
| 69 | 61 |
| 70 #endif // EXTENSIONS_RENDERER_DISPLAY_SOURCE_CUSTOM_BINDINGS_H_ | 62 #endif // EXTENSIONS_RENDERER_DISPLAY_SOURCE_CUSTOM_BINDINGS_H_ |
| OLD | NEW |