| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_BROWSER_CONNECTION_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_BROWSER_CONNECTION_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_PEPPER_BROWSER_CONNECTION_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_BROWSER_CONNECTION_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 // This class represents a connection from the renderer to the browser for | 22 // This class represents a connection from the renderer to the browser for |
| 23 // sending/receiving pepper ResourceHost related messages. When the browser | 23 // sending/receiving pepper ResourceHost related messages. When the browser |
| 24 // and renderer communicate about ResourceHosts, they should pass the plugin | 24 // and renderer communicate about ResourceHosts, they should pass the plugin |
| 25 // process ID to identify which plugin they are talking about. | 25 // process ID to identify which plugin they are talking about. |
| 26 class PepperBrowserConnection | 26 class PepperBrowserConnection |
| 27 : public RenderViewObserver, | 27 : public RenderViewObserver, |
| 28 public RenderViewObserverTracker<PepperBrowserConnection> { | 28 public RenderViewObserverTracker<PepperBrowserConnection> { |
| 29 public: | 29 public: |
| 30 typedef base::Callback<void(const std::vector<int>&)> | 30 typedef base::Callback<void(const std::vector<int>&)> |
| 31 PendingResourceIDCallback; | 31 PendingResourceIDCallback; |
| 32 typedef base::Callback<void( | |
| 33 const std::vector<PP_Resource>&, | |
| 34 const std::vector<PP_FileSystemType>&, | |
| 35 const std::vector<std::string>&, | |
| 36 const std::vector<base::FilePath>&)> FileRefGetInfoCallback; | |
| 37 | |
| 38 explicit PepperBrowserConnection(RenderView* render_view); | 32 explicit PepperBrowserConnection(RenderView* render_view); |
| 39 virtual ~PepperBrowserConnection(); | 33 virtual ~PepperBrowserConnection(); |
| 40 | 34 |
| 41 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 35 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 42 | 36 |
| 43 // TODO(teravest): Instead of having separate methods per message, we should | 37 // TODO(teravest): Instead of having separate methods per message, we should |
| 44 // add generic functionality similar to PluginResource::Call(). | 38 // add generic functionality similar to PluginResource::Call(). |
| 45 | 39 |
| 46 // Sends a request to the browser to create ResourceHosts for the given | 40 // Sends a request to the browser to create ResourceHosts for the given |
| 47 // |instance| of a plugin identified by |child_process_id|. |callback| will be | 41 // |instance| of a plugin identified by |child_process_id|. |callback| will be |
| 48 // run when a reply is received with the pending resource IDs. | 42 // run when a reply is received with the pending resource IDs. |
| 49 void SendBrowserCreate(PP_Instance instance, | 43 void SendBrowserCreate(PP_Instance instance, |
| 50 int child_process_id, | 44 int child_process_id, |
| 51 const std::vector<IPC::Message>& create_messages, | 45 const std::vector<IPC::Message>& create_messages, |
| 52 const PendingResourceIDCallback& callback); | 46 const PendingResourceIDCallback& callback); |
| 53 | 47 |
| 54 // Sends a request to the browser to get information about the given FileRef | |
| 55 // |resource|. |callback| will be run when a reply is received with the | |
| 56 // file information. | |
| 57 void SendBrowserFileRefGetInfo(int child_process_id, | |
| 58 const std::vector<PP_Resource>& resource, | |
| 59 const FileRefGetInfoCallback& callback); | |
| 60 | |
| 61 // Called when the renderer creates an in-process instance. | 48 // Called when the renderer creates an in-process instance. |
| 62 void DidCreateInProcessInstance(PP_Instance instance, | 49 void DidCreateInProcessInstance(PP_Instance instance, |
| 63 int render_view_id, | 50 int render_view_id, |
| 64 const GURL& document_url, | 51 const GURL& document_url, |
| 65 const GURL& plugin_url); | 52 const GURL& plugin_url); |
| 66 | 53 |
| 67 // Called when the renderer deletes an in-process instance. | 54 // Called when the renderer deletes an in-process instance. |
| 68 void DidDeleteInProcessInstance(PP_Instance instance); | 55 void DidDeleteInProcessInstance(PP_Instance instance); |
| 69 | 56 |
| 70 private: | 57 private: |
| 71 // Message handlers. | 58 // Message handlers. |
| 72 void OnMsgCreateResourceHostsFromHostReply( | 59 void OnMsgCreateResourceHostsFromHostReply( |
| 73 int32_t sequence_number, | 60 int32_t sequence_number, |
| 74 const std::vector<int>& pending_resource_host_ids); | 61 const std::vector<int>& pending_resource_host_ids); |
| 75 void OnMsgFileRefGetInfoReply( | |
| 76 int32_t sequence_number, | |
| 77 const std::vector<PP_Resource>& resources, | |
| 78 const std::vector<PP_FileSystemType>& types, | |
| 79 const std::vector<std::string>& file_system_url_specs, | |
| 80 const std::vector<base::FilePath>& external_paths); | |
| 81 | 62 |
| 82 // Return the next sequence number. | 63 // Return the next sequence number. |
| 83 int32_t GetNextSequence(); | 64 int32_t GetNextSequence(); |
| 84 | 65 |
| 85 // Sequence number to track pending callbacks. | 66 // Sequence number to track pending callbacks. |
| 86 int32_t next_sequence_number_; | 67 int32_t next_sequence_number_; |
| 87 | 68 |
| 88 // Maps a sequence number to the callback to be run. | 69 // Maps a sequence number to the callback to be run. |
| 89 std::map<int32_t, PendingResourceIDCallback> pending_create_map_; | 70 std::map<int32_t, PendingResourceIDCallback> pending_create_map_; |
| 90 std::map<int32_t, FileRefGetInfoCallback> get_info_map_; | |
| 91 DISALLOW_COPY_AND_ASSIGN(PepperBrowserConnection); | 71 DISALLOW_COPY_AND_ASSIGN(PepperBrowserConnection); |
| 92 }; | 72 }; |
| 93 | 73 |
| 94 } // namespace content | 74 } // namespace content |
| 95 | 75 |
| 96 #endif // CONTENT_RENDERER_PEPPER_PEPPER_BROWSER_CONNECTION_H_ | 76 #endif // CONTENT_RENDERER_PEPPER_PEPPER_BROWSER_CONNECTION_H_ |
| OLD | NEW |