| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_MESSAGING_BINDINGS_H_ | 5 #ifndef EXTENSIONS_RENDERER_MESSAGING_BINDINGS_H_ |
| 6 #define EXTENSIONS_RENDERER_MESSAGING_BINDINGS_H_ | 6 #define EXTENSIONS_RENDERER_MESSAGING_BINDINGS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 const std::string& error_message, | 63 const std::string& error_message, |
| 64 content::RenderFrame* restrict_to_render_frame); | 64 content::RenderFrame* restrict_to_render_frame); |
| 65 | 65 |
| 66 // Returns an existing port with the given |id|, or null. | 66 // Returns an existing port with the given |id|, or null. |
| 67 ExtensionPort* GetPortWithId(const PortId& id); | 67 ExtensionPort* GetPortWithId(const PortId& id); |
| 68 | 68 |
| 69 // Creates a new port with the given |id|. MessagingBindings owns the | 69 // Creates a new port with the given |id|. MessagingBindings owns the |
| 70 // returned port. | 70 // returned port. |
| 71 ExtensionPort* CreateNewPortWithId(const PortId& id); | 71 ExtensionPort* CreateNewPortWithId(const PortId& id); |
| 72 | 72 |
| 73 // Removes the port with the given |js_id|. | |
| 74 void RemovePortWithJsId(int js_id); | |
| 75 | |
| 76 const base::UnguessableToken& context_id() const { return context_id_; } | 73 const base::UnguessableToken& context_id() const { return context_id_; } |
| 77 | 74 |
| 78 base::WeakPtr<MessagingBindings> GetWeakPtr(); | 75 base::WeakPtr<MessagingBindings> GetWeakPtr(); |
| 79 | 76 |
| 80 private: | 77 private: |
| 81 using PortMap = std::map<int, std::unique_ptr<ExtensionPort>>; | 78 using PortMap = std::map<int, std::unique_ptr<ExtensionPort>>; |
| 82 | 79 |
| 83 // JS Exposed Function: Sends a message along the given channel. | 80 // JS Exposed Function: Sends a message along the given channel. |
| 84 void PostMessage(const v8::FunctionCallbackInfo<v8::Value>& args); | 81 void PostMessage(const v8::FunctionCallbackInfo<v8::Value>& args); |
| 85 | 82 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 const base::UnguessableToken context_id_; | 118 const base::UnguessableToken context_id_; |
| 122 | 119 |
| 123 base::WeakPtrFactory<MessagingBindings> weak_ptr_factory_; | 120 base::WeakPtrFactory<MessagingBindings> weak_ptr_factory_; |
| 124 | 121 |
| 125 DISALLOW_COPY_AND_ASSIGN(MessagingBindings); | 122 DISALLOW_COPY_AND_ASSIGN(MessagingBindings); |
| 126 }; | 123 }; |
| 127 | 124 |
| 128 } // namespace extensions | 125 } // namespace extensions |
| 129 | 126 |
| 130 #endif // EXTENSIONS_RENDERER_MESSAGING_BINDINGS_H_ | 127 #endif // EXTENSIONS_RENDERER_MESSAGING_BINDINGS_H_ |
| OLD | NEW |