Respond with QuotaExceededError when IndexedDB has no disk space on open.
[chromium-blink-merge.git] / content / browser / worker_host / message_port_service.h
blobb85e76b36b75dea0051b966dfdb9b891a388193c
1 // Copyright (c) 2012 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_BROWSER_WORKER_HOST_MESSAGE_PORT_SERVICE_H_
6 #define CONTENT_BROWSER_WORKER_HOST_MESSAGE_PORT_SERVICE_H_
8 #include <map>
9 #include <utility>
10 #include <vector>
12 #include "base/basictypes.h"
13 #include "base/memory/singleton.h"
14 #include "base/strings/string16.h"
15 #include "ipc/ipc_message.h"
17 namespace content {
18 class WorkerMessageFilter;
20 class MessagePortService {
21 public:
22 typedef std::vector<std::pair<string16, std::vector<int> > > QueuedMessages;
24 // Returns the MessagePortService singleton.
25 static MessagePortService* GetInstance();
27 // These methods correspond to the message port related IPCs.
28 void Create(int route_id, WorkerMessageFilter* filter, int* message_port_id);
29 void Destroy(int message_port_id);
30 void Entangle(int local_message_port_id, int remote_message_port_id);
31 void PostMessage(int sender_message_port_id,
32 const string16& message,
33 const std::vector<int>& sent_message_port_ids);
34 void QueueMessages(int message_port_id);
35 void SendQueuedMessages(int message_port_id,
36 const QueuedMessages& queued_messages);
38 // Updates the information needed to reach a message port when it's sent to a
39 // (possibly different) process.
40 void UpdateMessagePort(
41 int message_port_id,
42 WorkerMessageFilter* filter,
43 int routing_id);
45 void OnWorkerMessageFilterClosing(WorkerMessageFilter* filter);
47 // Attempts to send the queued messages for a message port.
48 void SendQueuedMessagesIfPossible(int message_port_id);
50 private:
51 friend struct DefaultSingletonTraits<MessagePortService>;
53 MessagePortService();
54 ~MessagePortService();
56 void PostMessageTo(int message_port_id,
57 const string16& message,
58 const std::vector<int>& sent_message_port_ids);
60 // Handles the details of removing a message port id. Before calling this,
61 // verify that the message port id exists.
62 void Erase(int message_port_id);
64 struct MessagePort;
65 typedef std::map<int, MessagePort> MessagePorts;
66 MessagePorts message_ports_;
68 // We need globally unique identifiers for each message port.
69 int next_message_port_id_;
71 DISALLOW_COPY_AND_ASSIGN(MessagePortService);
74 } // namespace content
76 #endif // CONTENT_BROWSER_WORKER_HOST_MESSAGE_PORT_SERVICE_H_