ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / content / public / browser / message_port_provider.h
blob4fdeb8468cdcbeaea22ef53856945bf6712e92b0
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_PUBLIC_BROWSER_MESSAGE_PORT_PROVIDER_H_
6 #define CONTENT_PUBLIC_BROWSER_MESSAGE_PORT_PROVIDER_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/macros.h"
12 #include "base/strings/string16.h"
13 #include "content/common/content_export.h"
15 namespace content {
17 class MessagePortDelegate;
18 class WebContents;
19 struct MessagePortMessage;
20 struct TransferredMessagePort;
22 // An interface consisting of methods that can be called to use Message ports.
23 class CONTENT_EXPORT MessagePortProvider {
24 public:
25 // Posts a MessageEvent to the main frame using the given source and target
26 // origins and data. The caller may also provide any message port ids as
27 // part of the message.
28 // See https://html.spec.whatwg.org/multipage/comms.html#messageevent for
29 // further information on message events.
30 // Should be called on UI thread.
31 static void PostMessageToFrame(
32 WebContents* web_contents,
33 const base::string16& source_origin,
34 const base::string16& target_origin,
35 const base::string16& data,
36 const std::vector<TransferredMessagePort>& ports);
38 // Creates a message channel and provide the ids of the message ports that are
39 // associated with this message channel.
40 // See https://html.spec.whatwg.org/multipage/comms.html#messagechannel
41 // Should be called on IO thread.
42 // The message ports that are created will have their routing id numbers equal
43 // to the message port numbers.
44 static void CreateMessageChannel(MessagePortDelegate* delegate,
45 int* port1,
46 int* port2);
48 // Posts a MessageEvent to a message port associated with a message channel.
49 static void PostMessageToPort(
50 int sender_port_id,
51 const MessagePortMessage& message,
52 const std::vector<TransferredMessagePort>& sent_ports);
54 // Close the message port. Should be called on IO thread.
55 static void ClosePort(int message_port_id);
57 // Cleanup the message ports that belong to the closing delegate.
58 static void OnMessagePortDelegateClosing(MessagePortDelegate * delegate);
60 private:
61 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePortProvider);
64 } // namespace content
66 #endif // CONTENT_PUBLIC_BROWSER_MESSAGE_PORT_PROVIDER_H_