OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 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. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_BROWSER_CONNECTION_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_PEPPER_BROWSER_CONNECTION_H_ |
| 7 |
| 8 #include <map> |
| 9 |
| 10 #include "base/callback.h" |
| 11 #include "content/public/renderer/render_view_observer.h" |
| 12 #include "ppapi/c/pp_instance.h" |
| 13 |
| 14 namespace content { |
| 15 |
| 16 class RenderView; |
| 17 |
| 18 // This class represents a connection from the renderer to the browser for |
| 19 // sending/receiving pepper ResourceHost related messages. When the browser |
| 20 // and renderer communicate about ResourceHosts, they should pass the plugin |
| 21 // process ID to identify which plugin they are talking about. |
| 22 class PepperBrowserConnection : public RenderViewObserver { |
| 23 public: |
| 24 typedef base::Callback<void(int)> PendingResourceIDCallback; |
| 25 |
| 26 explicit PepperBrowserConnection(RenderView* render_view); |
| 27 virtual ~PepperBrowserConnection(); |
| 28 |
| 29 // RenderViewObserver overrides. |
| 30 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 31 |
| 32 // Sends a request to the browser to create a ResourceHost for the given |
| 33 // |instance| of a plugin identified by |child_process_id|. |callback| will be |
| 34 // run when a reply is received with the pending resource ID. |
| 35 void SendBrowserCreate(PP_Instance instance, |
| 36 int child_process_id, |
| 37 const IPC::Message& create_message, |
| 38 PendingResourceIDCallback callback); |
| 39 |
| 40 private: |
| 41 // Message handlers. |
| 42 void OnMsgCreateResourceHostFromHostReply(int32_t sequence_number, |
| 43 int pending_resource_host_id); |
| 44 |
| 45 // Return the next sequence number. |
| 46 int32_t GetNextSequence(); |
| 47 |
| 48 // Sequence number to track pending callbacks. |
| 49 int32_t next_sequence_number_; |
| 50 |
| 51 // Maps a sequence number to the callback to be run. |
| 52 std::map<int32_t, PendingResourceIDCallback> pending_create_map_; |
| 53 |
| 54 DISALLOW_COPY_AND_ASSIGN(PepperBrowserConnection); |
| 55 }; |
| 56 |
| 57 } // namespace content |
| 58 |
| 59 #endif // CONTENT_RENDERER_PEPPER_PEPPER_BROWSER_CONNECTION_H_ |
OLD | NEW |