Chromium Code Reviews| Index: content/renderer/pepper/pepper_browser_connection.h |
| diff --git a/content/renderer/pepper/pepper_browser_connection.h b/content/renderer/pepper/pepper_browser_connection.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ebbfaea7fe5f1739baf1ba30b48b5579c0a135b3 |
| --- /dev/null |
| +++ b/content/renderer/pepper/pepper_browser_connection.h |
| @@ -0,0 +1,59 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_RENDERER_PEPPER_PEPPER_BROWSER_CONNECTION_H_ |
| +#define CONTENT_RENDERER_PEPPER_PEPPER_BROWSER_CONNECTION_H_ |
| + |
| +#include <map> |
| + |
| +#include "base/callback.h" |
| +#include "content/public/renderer/render_view_observer.h" |
| +#include "ppapi/c/pp_instance.h" |
| + |
| +namespace content { |
| + |
| +class RenderView; |
| + |
| +// This class represents a connection from the renderer to the browser for |
| +// sending/receiving pepper ResourceHost related messages. When the browser |
| +// and renderer communicate about ResourceHosts, they should pass the plugin |
| +// process ID to identify which plugin they are talking about. |
| +class PepperBrowserConnection : public RenderViewObserver { |
| + public: |
| + typedef base::Callback<void(int)> PendingResourceIDCallback; |
| + |
| + explicit PepperBrowserConnection(RenderView* render_view); |
| + virtual ~PepperBrowserConnection(); |
| + |
| + // RenderViewObserver overrides. |
| + virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| + |
| + // Sends a request to the browser to create a ResourceHost for the given |
| + // |instance| of a plugin identified by |child_process_id|. |callback| will be |
| + // run when a reply is received with the pending resource ID. |
| + void SendBrowserCreate(PP_Instance instance, |
| + int child_process_id, |
| + const IPC::Message& create_message, |
| + PendingResourceIDCallback callback); |
|
yzshen1
2013/05/29 17:57:21
const &?
raymes
2013/06/04 04:11:11
Done.
|
| + |
| + private: |
| + // Message handlers. |
| + void OnMsgCreateResourceHostFromHostReply(int32_t sequence_number, |
| + int pending_resource_host_id); |
| + |
| + // Return the next sequence number. |
| + int32_t GetNextSequence(); |
| + |
| + // Sequence number to track pending callbacks. |
| + int32_t next_sequence_number_; |
| + |
| + // Maps a sequence number to the callback to be run. |
| + std::map<int32_t, PendingResourceIDCallback> pending_create_map_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PepperBrowserConnection); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_RENDERER_PEPPER_PEPPER_BROWSER_CONNECTION_H_ |