| Index: chrome/browser/worker_host/message_port_service.h
|
| ===================================================================
|
| --- chrome/browser/worker_host/message_port_service.h (revision 69328)
|
| +++ chrome/browser/worker_host/message_port_service.h (working copy)
|
| @@ -2,8 +2,8 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef CHROME_BROWSER_WORKER_HOST_MESSAGE_PORT_DISPATCHER_H_
|
| -#define CHROME_BROWSER_WORKER_HOST_MESSAGE_PORT_DISPATCHER_H_
|
| +#ifndef CHROME_BROWSER_WORKER_HOST_MESSAGE_PORT_SERVICE_H_
|
| +#define CHROME_BROWSER_WORKER_HOST_MESSAGE_PORT_SERVICE_H_
|
| #pragma once
|
|
|
| #include <map>
|
| @@ -11,65 +11,53 @@
|
| #include <vector>
|
|
|
| #include "base/basictypes.h"
|
| -#include "base/callback.h"
|
| #include "base/singleton.h"
|
| #include "base/string16.h"
|
| #include "base/task.h"
|
| -#include "chrome/common/notification_observer.h"
|
| -#include "chrome/common/notification_registrar.h"
|
| #include "ipc/ipc_message.h"
|
|
|
| -class MessagePortDispatcher : public NotificationObserver {
|
| +class WorkerMessageFilter;
|
| +
|
| +class MessagePortService {
|
| public:
|
| typedef std::vector<std::pair<string16, std::vector<int> > > QueuedMessages;
|
|
|
| - // Returns the MessagePortDispatcher singleton.
|
| - static MessagePortDispatcher* GetInstance();
|
| + // Returns the MessagePortService singleton.
|
| + static MessagePortService* GetInstance();
|
|
|
| - bool OnMessageReceived(const IPC::Message& message,
|
| - IPC::Message::Sender* sender,
|
| - CallbackWithReturnValue<int>::Type* next_routing_id,
|
| - bool* message_was_ok);
|
| + // These methods correspond to the message port related IPCs.
|
| + void Create(int route_id, WorkerMessageFilter* filter, int* message_port_id);
|
| + void Destroy(int message_port_id);
|
| + void Entangle(int local_message_port_id, int remote_message_port_id);
|
| + void PostMessage(int sender_message_port_id,
|
| + const string16& message,
|
| + const std::vector<int>& sent_message_port_ids);
|
| + void QueueMessages(int message_port_id);
|
| + void SendQueuedMessages(int message_port_id,
|
| + const QueuedMessages& queued_messages);
|
|
|
| // Updates the information needed to reach a message port when it's sent to a
|
| // (possibly different) process.
|
| void UpdateMessagePort(
|
| int message_port_id,
|
| - IPC::Message::Sender* sender,
|
| - int routing_id,
|
| - CallbackWithReturnValue<int>::Type* next_routing_id);
|
| + WorkerMessageFilter* filter,
|
| + int routing_id);
|
|
|
| + void OnWorkerMessageFilterClosing(WorkerMessageFilter* filter);
|
| +
|
| // Attempts to send the queued messages for a message port.
|
| void SendQueuedMessagesIfPossible(int message_port_id);
|
|
|
| - bool Send(IPC::Message* message);
|
| -
|
| private:
|
| - friend struct DefaultSingletonTraits<MessagePortDispatcher>;
|
| + friend struct DefaultSingletonTraits<MessagePortService>;
|
|
|
| - MessagePortDispatcher();
|
| - ~MessagePortDispatcher();
|
| + MessagePortService();
|
| + ~MessagePortService();
|
|
|
| - // Message handlers.
|
| - void OnCreate(int* route_id, int* message_port_id);
|
| - void OnDestroy(int message_port_id);
|
| - void OnEntangle(int local_message_port_id, int remote_message_port_id);
|
| - void OnPostMessage(int sender_message_port_id,
|
| - const string16& message,
|
| - const std::vector<int>& sent_message_port_ids);
|
| - void OnQueueMessages(int message_port_id);
|
| - void OnSendQueuedMessages(int message_port_id,
|
| - const QueuedMessages& queued_messages);
|
| -
|
| void PostMessageTo(int message_port_id,
|
| const string16& message,
|
| const std::vector<int>& sent_message_port_ids);
|
|
|
| - // NotificationObserver interface.
|
| - virtual void Observe(NotificationType type,
|
| - const NotificationSource& source,
|
| - const NotificationDetails& details);
|
| -
|
| // Handles the details of removing a message port id. Before calling this,
|
| // verify that the message port id exists.
|
| void Erase(int message_port_id);
|
| @@ -81,13 +69,7 @@
|
| // We need globally unique identifiers for each message port.
|
| int next_message_port_id_;
|
|
|
| - // Valid only during IPC message dispatching.
|
| - IPC::Message::Sender* sender_;
|
| - CallbackWithReturnValue<int>::Type* next_routing_id_;
|
| -
|
| - NotificationRegistrar registrar_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(MessagePortDispatcher);
|
| + DISALLOW_COPY_AND_ASSIGN(MessagePortService);
|
| };
|
|
|
| -#endif // CHROME_BROWSER_WORKER_HOST_MESSAGE_PORT_DISPATCHER_H_
|
| +#endif // CHROME_BROWSER_WORKER_HOST_MESSAGE_PORT_SERVICE_H_
|
|
|