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

Side by Side Diff: content/browser/message_port_service.h

Issue 921013002: Optionally have MessagePort pass data as base::Value, part 1. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@n-c-move-v8-value-converter
Patch Set: Update singly-included comment 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_BROWSER_MESSAGE_PORT_SERVICE_H_ 5 #ifndef CONTENT_BROWSER_MESSAGE_PORT_SERVICE_H_
6 #define CONTENT_BROWSER_MESSAGE_PORT_SERVICE_H_ 6 #define CONTENT_BROWSER_MESSAGE_PORT_SERVICE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/memory/singleton.h" 13 #include "base/memory/singleton.h"
14 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
15 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
16 #include "content/public/common/message_port_types.h"
16 #include "ipc/ipc_message.h" 17 #include "ipc/ipc_message.h"
17 18
18 namespace content { 19 namespace content {
19 class MessagePortDelegate; 20 class MessagePortDelegate;
20 21
21 class CONTENT_EXPORT MessagePortService { 22 class CONTENT_EXPORT MessagePortService {
22 public: 23 public:
23 typedef std::vector<std::pair<base::string16, std::vector<int> > > 24 typedef std::vector<std::pair<content::MessagePortMessage, std::vector<int>>>
24 QueuedMessages; 25 QueuedMessages;
25 26
26 // Returns the MessagePortService singleton. 27 // Returns the MessagePortService singleton.
27 static MessagePortService* GetInstance(); 28 static MessagePortService* GetInstance();
28 29
29 // These methods correspond to the message port related IPCs. 30 // These methods correspond to the message port related IPCs.
30 void Create(int route_id, 31 void Create(int route_id,
31 MessagePortDelegate* delegate, 32 MessagePortDelegate* delegate,
32 int* message_port_id); 33 int* message_port_id);
33 void Destroy(int message_port_id); 34 void Destroy(int message_port_id);
34 void Entangle(int local_message_port_id, int remote_message_port_id); 35 void Entangle(int local_message_port_id, int remote_message_port_id);
35 void PostMessage(int sender_message_port_id, 36 void PostMessage(int sender_message_port_id,
36 const base::string16& message, 37 const MessagePortMessage& message,
37 const std::vector<int>& sent_message_port_ids); 38 const std::vector<int>& sent_message_port_ids);
38 void QueueMessages(int message_port_id); 39 void QueueMessages(int message_port_id);
39 void SendQueuedMessages(int message_port_id, 40 void SendQueuedMessages(int message_port_id,
40 const QueuedMessages& queued_messages); 41 const QueuedMessages& queued_messages);
41 void ReleaseMessages(int message_port_id); 42 void ReleaseMessages(int message_port_id);
42 43
43 // Updates the information needed to reach a message port when it's sent to a 44 // Updates the information needed to reach a message port when it's sent to a
44 // (possibly different) process. 45 // (possibly different) process.
45 void UpdateMessagePort(int message_port_id, 46 void UpdateMessagePort(int message_port_id,
46 MessagePortDelegate* delegate, 47 MessagePortDelegate* delegate,
(...skipping 18 matching lines...) Expand all
65 // Attempts to send the queued messages for a message port. 66 // Attempts to send the queued messages for a message port.
66 void SendQueuedMessagesIfPossible(int message_port_id); 67 void SendQueuedMessagesIfPossible(int message_port_id);
67 68
68 private: 69 private:
69 friend struct DefaultSingletonTraits<MessagePortService>; 70 friend struct DefaultSingletonTraits<MessagePortService>;
70 71
71 MessagePortService(); 72 MessagePortService();
72 ~MessagePortService(); 73 ~MessagePortService();
73 74
74 void PostMessageTo(int message_port_id, 75 void PostMessageTo(int message_port_id,
75 const base::string16& message, 76 const MessagePortMessage& message,
76 const std::vector<int>& sent_message_port_ids); 77 const std::vector<int>& sent_message_port_ids);
77 78
78 // Handles the details of removing a message port id. Before calling this, 79 // Handles the details of removing a message port id. Before calling this,
79 // verify that the message port id exists. 80 // verify that the message port id exists.
80 void Erase(int message_port_id); 81 void Erase(int message_port_id);
81 82
82 struct MessagePort; 83 struct MessagePort;
83 typedef std::map<int, MessagePort> MessagePorts; 84 typedef std::map<int, MessagePort> MessagePorts;
84 MessagePorts message_ports_; 85 MessagePorts message_ports_;
85 86
86 // We need globally unique identifiers for each message port. 87 // We need globally unique identifiers for each message port.
87 int next_message_port_id_; 88 int next_message_port_id_;
88 89
89 DISALLOW_COPY_AND_ASSIGN(MessagePortService); 90 DISALLOW_COPY_AND_ASSIGN(MessagePortService);
90 }; 91 };
91 92
92 } // namespace content 93 } // namespace content
93 94
94 #endif // CONTENT_BROWSER_MESSAGE_PORT_SERVICE_H_ 95 #endif // CONTENT_BROWSER_MESSAGE_PORT_SERVICE_H_
OLDNEW
« no previous file with comments | « content/browser/message_port_provider_browsertest.cc ('k') | content/browser/message_port_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698