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

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

Issue 1966283002: Remove port lifetime management from renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use MakeUnique instead of WrapUnique Created 4 years, 6 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 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 "extensions/renderer/script_context_set.h" 10 #include "extensions/renderer/script_context_set.h"
11 11
12 struct ExtensionMsg_ExternalConnectionInfo; 12 struct ExtensionMsg_ExternalConnectionInfo;
13 struct ExtensionMsg_TabConnectionInfo; 13 struct ExtensionMsg_TabConnectionInfo;
14 14
15 namespace base { 15 namespace base {
16 class DictionaryValue; 16 class DictionaryValue;
17 } 17 }
18 18
19 namespace content { 19 namespace content {
20 class RenderFrame; 20 class RenderFrame;
21 } 21 }
22 22
23 namespace v8 { 23 namespace v8 {
24 class Extension; 24 class Extension;
25 } 25 }
26 26
27 namespace extensions { 27 namespace extensions {
28 class Dispatcher;
29 struct Message; 28 struct Message;
30 class ObjectBackedNativeHandler; 29 class ObjectBackedNativeHandler;
31 class ScriptContextSet; 30 class ScriptContextSet;
32 31
33 // Manually implements JavaScript bindings for extension messaging. 32 // Manually implements JavaScript bindings for extension messaging.
34 // 33 //
35 // TODO(aa): This should all get re-implemented using SchemaGeneratedBindings. 34 // TODO(aa): This should all get re-implemented using SchemaGeneratedBindings.
36 // If anything needs to be manual for some reason, it should be implemented in 35 // If anything needs to be manual for some reason, it should be implemented in
37 // its own class. 36 // its own class.
38 class MessagingBindings { 37 class MessagingBindings {
39 public: 38 public:
40 // Creates an instance of the extension. 39 // Creates an instance of the extension.
41 static ObjectBackedNativeHandler* Get(Dispatcher* dispatcher, 40 static ObjectBackedNativeHandler* Get(ScriptContext* context);
42 ScriptContext* context); 41
42 // Checks whether the port exists in the given frame. If it does not, a reply
43 // is sent back to the browser.
44 static void ValidateMessagePort(const ScriptContextSet& context_set,
45 int port_id,
46 content::RenderFrame* render_frame);
43 47
44 // Dispatches the onConnect content script messaging event to some contexts 48 // Dispatches the onConnect content script messaging event to some contexts
45 // in |context_set|. If |restrict_to_render_frame| is specified, only contexts 49 // in |context_set|. If |restrict_to_render_frame| is specified, only contexts
46 // in that render frame will receive the message. 50 // in that render frame will receive the message.
47 static void DispatchOnConnect(const ScriptContextSet& context_set, 51 static void DispatchOnConnect(const ScriptContextSet& context_set,
48 int target_port_id, 52 int target_port_id,
49 const std::string& channel_name, 53 const std::string& channel_name,
50 const ExtensionMsg_TabConnectionInfo& source, 54 const ExtensionMsg_TabConnectionInfo& source,
51 const ExtensionMsg_ExternalConnectionInfo& info, 55 const ExtensionMsg_ExternalConnectionInfo& info,
52 const std::string& tls_channel_id, 56 const std::string& tls_channel_id,
(...skipping 11 matching lines...) Expand all
64 static void DispatchOnDisconnect( 68 static void DispatchOnDisconnect(
65 const ScriptContextSet& context_set, 69 const ScriptContextSet& context_set,
66 int port_id, 70 int port_id,
67 const std::string& error_message, 71 const std::string& error_message,
68 content::RenderFrame* restrict_to_render_frame); 72 content::RenderFrame* restrict_to_render_frame);
69 }; 73 };
70 74
71 } // namespace extensions 75 } // namespace extensions
72 76
73 #endif // EXTENSIONS_RENDERER_MESSAGING_BINDINGS_H_ 77 #endif // EXTENSIONS_RENDERER_MESSAGING_BINDINGS_H_
OLDNEW
« no previous file with comments | « extensions/renderer/extension_frame_helper.cc ('k') | extensions/renderer/messaging_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698