| Index: extensions/renderer/extension_port.h
|
| diff --git a/extensions/renderer/extension_port.h b/extensions/renderer/extension_port.h
|
| index def591073886e3f0e3f52d0ca890dd02926eb5b6..9c73fbea976ee7e316fd6382c4ed0e3aaf5f21df 100644
|
| --- a/extensions/renderer/extension_port.h
|
| +++ b/extensions/renderer/extension_port.h
|
| @@ -6,17 +6,15 @@
|
| #define EXTENSIONS_RENDERER_EXTENSION_PORT_H_
|
|
|
| #include <memory>
|
| +#include <utility>
|
| #include <vector>
|
|
|
| #include "base/macros.h"
|
| -
|
| -namespace content {
|
| -class RenderFrame;
|
| -}
|
| +#include "extensions/common/api/messaging/port_id.h"
|
|
|
| namespace extensions {
|
| -
|
| struct Message;
|
| +struct PortId;
|
| class ScriptContext;
|
|
|
| // A class representing information about a specific extension message port that
|
| @@ -24,13 +22,9 @@ class ScriptContext;
|
| // assigned asynchronously, this object caches pending messages.
|
| class ExtensionPort {
|
| public:
|
| - ExtensionPort(ScriptContext* script_context, int local_id);
|
| + ExtensionPort(ScriptContext* script_context, const PortId& id, int js_id);
|
| ~ExtensionPort();
|
|
|
| - // Sets the global id of the port (that is, the id used in the browser
|
| - // process to send/receive messages). Any pending messages will be sent.
|
| - void SetGlobalId(int id);
|
| -
|
| // Posts a new message to the port. If the port is not initialized, the
|
| // message will be queued until it is.
|
| void PostExtensionMessage(std::unique_ptr<Message> message);
|
| @@ -39,36 +33,20 @@ class ExtensionPort {
|
| // assuming initialization completes (after which, the port will close).
|
| void Close(bool close_channel);
|
|
|
| - int local_id() const { return local_id_; }
|
| - int global_id() const { return global_id_; }
|
| - bool initialized() const { return global_id_ != -1; }
|
| + const PortId& id() const { return id_; }
|
| + int js_id() const { return js_id_; }
|
|
|
| private:
|
| - // Helper function to send the post message IPC.
|
| - void PostMessageImpl(content::RenderFrame* render_frame,
|
| - const Message& message);
|
| -
|
| - // Sends the message to the browser that this port has been disconnected.
|
| - void SendDisconnected(content::RenderFrame* render_frame);
|
| -
|
| // The associated ScriptContext for this port. Since these objects are owned
|
| // by a NativeHandler, this should always be valid.
|
| ScriptContext* script_context_ = nullptr;
|
|
|
| - // The local id of the port (used within JS bindings).
|
| - int local_id_ = -1;
|
| -
|
| - // The global id of the port (used by the browser process).
|
| - int global_id_ = -1;
|
| -
|
| - // The queue of any pending messages to be sent once the port is initialized.
|
| - std::vector<std::unique_ptr<Message>> pending_messages_;
|
| -
|
| - // Whether or not the port is disconnected.
|
| - bool is_disconnected_ = false;
|
| + const PortId id_;
|
|
|
| - // Whether to close the full message channel.
|
| - bool close_channel_ = false;
|
| + // The id used in the JS bindings. If this is a receiver port, this is not the
|
| + // same as the port_number in the PortId. This should be used only as an
|
| + // identifier in the JS context this port is from.
|
| + int js_id_ = 0;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(ExtensionPort);
|
| };
|
|
|