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

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

Issue 944443003: Step two of optionally sending messages to/from message ports as base::Value. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@n-c-message-as-values-take2
Patch Set: use auto where it makes sense Created 5 years, 9 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/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
13 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
14 14
15 namespace content { 15 namespace content {
16 16
17 class MessagePortDelegate; 17 class MessagePortDelegate;
18 class WebContents;
18 struct MessagePortMessage; 19 struct MessagePortMessage;
19 class WebContents; 20 struct TransferredMessagePort;
20 21
21 // An interface consisting of methods that can be called to use Message ports. 22 // An interface consisting of methods that can be called to use Message ports.
22 class CONTENT_EXPORT MessagePortProvider { 23 class CONTENT_EXPORT MessagePortProvider {
23 public: 24 public:
24 // Posts a MessageEvent to the main frame using the given source and target 25 // Posts a MessageEvent to the main frame using the given source and target
25 // origins and data. The caller may also provide any message port ids as 26 // origins and data. The caller may also provide any message port ids as
26 // part of the message. 27 // part of the message.
27 // See https://html.spec.whatwg.org/multipage/comms.html#messageevent for 28 // See https://html.spec.whatwg.org/multipage/comms.html#messageevent for
28 // further information on message events. 29 // further information on message events.
29 // Should be called on UI thread. 30 // Should be called on UI thread.
30 static void PostMessageToFrame(WebContents* web_contents, 31 static void PostMessageToFrame(
31 const base::string16& source_origin, 32 WebContents* web_contents,
32 const base::string16& target_origin, 33 const base::string16& source_origin,
33 const base::string16& data, 34 const base::string16& target_origin,
34 const std::vector<int>& ports); 35 const base::string16& data,
36 const std::vector<TransferredMessagePort>& ports);
35 37
36 // Creates a message channel and provide the ids of the message ports that are 38 // Creates a message channel and provide the ids of the message ports that are
37 // associated with this message channel. 39 // associated with this message channel.
38 // See https://html.spec.whatwg.org/multipage/comms.html#messagechannel 40 // See https://html.spec.whatwg.org/multipage/comms.html#messagechannel
39 // Should be called on IO thread. 41 // Should be called on IO thread.
40 // The message ports that are created will have their routing id numbers equal 42 // The message ports that are created will have their routing id numbers equal
41 // to the message port numbers. 43 // to the message port numbers.
42 static void CreateMessageChannel(MessagePortDelegate* delegate, 44 static void CreateMessageChannel(MessagePortDelegate* delegate,
43 int* port1, 45 int* port1,
44 int* port2); 46 int* port2);
45 47
46 // Posts a MessageEvent to a message port associated with a message channel. 48 // Posts a MessageEvent to a message port associated with a message channel.
47 static void PostMessageToPort(int sender_port_id, 49 static void PostMessageToPort(
48 const MessagePortMessage& message, 50 int sender_port_id,
49 const std::vector<int>& sent_ports); 51 const MessagePortMessage& message,
52 const std::vector<TransferredMessagePort>& sent_ports);
50 53
51 // Close the message port. Should be called on IO thread. 54 // Close the message port. Should be called on IO thread.
52 static void ClosePort(int message_port_id); 55 static void ClosePort(int message_port_id);
53 56
54 // Cleanup the message ports that belong to the closing delegate. 57 // Cleanup the message ports that belong to the closing delegate.
55 static void OnMessagePortDelegateClosing(MessagePortDelegate * delegate); 58 static void OnMessagePortDelegateClosing(MessagePortDelegate * delegate);
56 59
57 private: 60 private:
58 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePortProvider); 61 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePortProvider);
59 }; 62 };
60 63
61 } // namespace content 64 } // namespace content
62 65
63 #endif // CONTENT_PUBLIC_BROWSER_MESSAGE_PORT_PROVIDER_H_ 66 #endif // CONTENT_PUBLIC_BROWSER_MESSAGE_PORT_PROVIDER_H_
OLDNEW
« no previous file with comments | « content/public/browser/message_port_delegate.h ('k') | content/public/common/message_port_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698