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

Side by Side Diff: content/public/browser/message_port_provider.h

Issue 2375133002: Move MessagePort implementation from android_webview to content (Closed)
Patch Set: rsesek nits and git cl format Created 4 years, 2 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 CONTENT_PUBLIC_BROWSER_MESSAGE_PORT_PROVIDER_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_MESSAGE_PORT_PROVIDER_H_
6 #define CONTENT_PUBLIC_BROWSER_MESSAGE_PORT_PROVIDER_H_ 6 #define CONTENT_PUBLIC_BROWSER_MESSAGE_PORT_PROVIDER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/singleton.h"
11 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
12 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
13 14
14 namespace content { 15 namespace content {
15 16
17 class AppWebMessagePortService;
18 class WebContents;
16 class MessagePortDelegate; 19 class MessagePortDelegate;
17 class WebContents;
18 20
19 // An interface consisting of methods that can be called to use Message ports. 21 // An interface consisting of methods that can be called to use Message ports.
20 class CONTENT_EXPORT MessagePortProvider { 22 class CONTENT_EXPORT MessagePortProvider {
21 public: 23 public:
22 // Posts a MessageEvent to the main frame using the given source and target 24 // Posts a MessageEvent to the main frame using the given source and target
23 // origins and data. The caller may also provide any message port ids as 25 // origins and data. The caller may also provide any message port ids as
24 // part of the message. 26 // part of the message.
25 // See https://html.spec.whatwg.org/multipage/comms.html#messageevent for 27 // See https://html.spec.whatwg.org/multipage/comms.html#messageevent for
26 // further information on message events. 28 // further information on message events.
27 // Should be called on UI thread. 29 // Should be called on UI thread.
28 static void PostMessageToFrame( 30 static void PostMessageToFrame(
29 WebContents* web_contents, 31 WebContents* web_contents,
30 const base::string16& source_origin, 32 const base::string16& source_origin,
31 const base::string16& target_origin, 33 const base::string16& target_origin,
32 const base::string16& data, 34 const base::string16& data,
33 const std::vector<int>& ports); 35 const std::vector<int>& ports);
34 36
35 // Creates a message channel and provide the ids of the message ports that are 37 #if defined(OS_ANDROID)
36 // associated with this message channel. 38 static content::AppWebMessagePortService* GetAppWebMessagePortService();
37 // See https://html.spec.whatwg.org/multipage/comms.html#messagechannel 39 #endif
38 // Should be called on IO thread.
39 // The message ports that are created will have their routing id numbers equal
40 // to the message port numbers.
41 static void CreateMessageChannel(MessagePortDelegate* delegate,
42 int* port1,
43 int* port2);
44
45 // Posts a MessageEvent to a message port associated with a message channel.
46 // Should be called on IO thread.
47 static void PostMessageToPort(
48 int sender_port_id,
49 const base::string16& message,
50 const std::vector<int>& sent_ports);
51
52 // Close the message port. Should be called on IO thread.
53 static void ClosePort(int message_port_id);
54
55 // Queue up all the messages for this message port until ReleaseMessages
56 // is called. Should be called on IO thread.
57 static void HoldMessages(int message_port_id);
58
59 // Release any queued messages as a result of HoldMessages. Should be
60 // called on IO thread.
61 static void ReleaseMessages(int message_port_id);
62
63 // Cleanup the message ports that belong to the closing delegate.
64 // Should be called on IO thread.
65 static void OnMessagePortDelegateClosing(MessagePortDelegate * delegate);
66
67 // Update message port information when the message port is transferred
68 // from a different process. The updated message ports will have their
69 // routing numbers equal to the message port numbers.
70 // Should be called on IO thread.
71 static void UpdateMessagePort(int message_port_id,
72 MessagePortDelegate* delegate);
73 40
74 private: 41 private:
75 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePortProvider); 42 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePortProvider);
76 }; 43 };
77 44
78 } // namespace content 45 } // namespace content
79 46
80 #endif // CONTENT_PUBLIC_BROWSER_MESSAGE_PORT_PROVIDER_H_ 47 #endif // CONTENT_PUBLIC_BROWSER_MESSAGE_PORT_PROVIDER_H_
OLDNEW
« no previous file with comments | « content/public/browser/android/app_web_message_port_service.h ('k') | content/renderer/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698