| 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 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "content/public/renderer/render_view_observer.h" | 13 #include "content/public/renderer/render_view_observer.h" |
| 14 #include "ppapi/c/pp_file_info.h" | 14 #include "ppapi/c/pp_file_info.h" |
| 15 #include "ppapi/c/pp_instance.h" | 15 #include "ppapi/c/pp_instance.h" |
| 16 #include "ppapi/c/pp_resource.h" | 16 #include "ppapi/c/pp_resource.h" |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 | 19 |
| 20 class PepperPluginDelegateImpl; | 20 class PepperHelperImpl; |
| 21 | 21 |
| 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: | 27 public: |
| 28 typedef base::Callback<void(int)> PendingResourceIDCallback; | 28 typedef base::Callback<void(int)> PendingResourceIDCallback; |
| 29 typedef base::Callback<void(PP_FileSystemType, | 29 typedef base::Callback<void(PP_FileSystemType, |
| 30 std::string, | 30 std::string, |
| 31 base::FilePath)> FileRefGetInfoCallback; | 31 base::FilePath)> FileRefGetInfoCallback; |
| 32 | 32 |
| 33 explicit PepperBrowserConnection(PepperPluginDelegateImpl* plugin_delegate); | 33 explicit PepperBrowserConnection(PepperHelperImpl* helper); |
| 34 virtual ~PepperBrowserConnection(); | 34 virtual ~PepperBrowserConnection(); |
| 35 | 35 |
| 36 bool OnMessageReceived(const IPC::Message& message); | 36 bool OnMessageReceived(const IPC::Message& message); |
| 37 | 37 |
| 38 // TODO(teravest): Instead of having separate methods per message, we should | 38 // TODO(teravest): Instead of having separate methods per message, we should |
| 39 // add generic functionality similar to PluginResource::Call(). | 39 // add generic functionality similar to PluginResource::Call(). |
| 40 | 40 |
| 41 // Sends a request to the browser to create a ResourceHost for the given | 41 // Sends a request to the browser to create a ResourceHost for the given |
| 42 // |instance| of a plugin identified by |child_process_id|. |callback| will be | 42 // |instance| of a plugin identified by |child_process_id|. |callback| will be |
| 43 // run when a reply is received with the pending resource ID. | 43 // run when a reply is received with the pending resource ID. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 58 void OnMsgCreateResourceHostFromHostReply(int32_t sequence_number, | 58 void OnMsgCreateResourceHostFromHostReply(int32_t sequence_number, |
| 59 int pending_resource_host_id); | 59 int pending_resource_host_id); |
| 60 void OnMsgFileRefGetInfoReply(int32_t sequence_number, | 60 void OnMsgFileRefGetInfoReply(int32_t sequence_number, |
| 61 PP_FileSystemType type, | 61 PP_FileSystemType type, |
| 62 std::string file_system_url_spec, | 62 std::string file_system_url_spec, |
| 63 base::FilePath external_path); | 63 base::FilePath external_path); |
| 64 | 64 |
| 65 // Return the next sequence number. | 65 // Return the next sequence number. |
| 66 int32_t GetNextSequence(); | 66 int32_t GetNextSequence(); |
| 67 | 67 |
| 68 // The plugin delegate that owns us. | 68 // The plugin helper that owns us. |
| 69 PepperPluginDelegateImpl* plugin_delegate_; | 69 PepperHelperImpl* helper_; |
| 70 | 70 |
| 71 // Sequence number to track pending callbacks. | 71 // Sequence number to track pending callbacks. |
| 72 int32_t next_sequence_number_; | 72 int32_t next_sequence_number_; |
| 73 | 73 |
| 74 // Maps a sequence number to the callback to be run. | 74 // Maps a sequence number to the callback to be run. |
| 75 std::map<int32_t, PendingResourceIDCallback> pending_create_map_; | 75 std::map<int32_t, PendingResourceIDCallback> pending_create_map_; |
| 76 std::map<int32_t, FileRefGetInfoCallback> get_info_map_; | 76 std::map<int32_t, FileRefGetInfoCallback> get_info_map_; |
| 77 DISALLOW_COPY_AND_ASSIGN(PepperBrowserConnection); | 77 DISALLOW_COPY_AND_ASSIGN(PepperBrowserConnection); |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 } // namespace content | 80 } // namespace content |
| 81 | 81 |
| 82 #endif // CONTENT_RENDERER_PEPPER_PEPPER_BROWSER_CONNECTION_H_ | 82 #endif // CONTENT_RENDERER_PEPPER_PEPPER_BROWSER_CONNECTION_H_ |
| OLD | NEW |