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> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "content/public/renderer/render_view_observer.h" | 14 #include "content/public/renderer/render_view_observer.h" |
15 #include "content/public/renderer/render_view_observer_tracker.h" | 15 #include "content/public/renderer/render_view_observer_tracker.h" |
16 #include "ppapi/c/pp_file_info.h" | 16 #include "ppapi/c/pp_file_info.h" |
17 #include "ppapi/c/pp_instance.h" | 17 #include "ppapi/c/pp_instance.h" |
18 #include "ppapi/c/pp_resource.h" | 18 #include "ppapi/c/pp_resource.h" |
19 #include "ppapi/shared_impl/file_ref_detailed_info.h" | |
20 | 19 |
21 namespace content { | 20 namespace content { |
22 | 21 |
23 // 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 |
24 // sending/receiving pepper ResourceHost related messages. When the browser | 23 // sending/receiving pepper ResourceHost related messages. When the browser |
25 // and renderer communicate about ResourceHosts, they should pass the plugin | 24 // and renderer communicate about ResourceHosts, they should pass the plugin |
26 // process ID to identify which plugin they are talking about. | 25 // process ID to identify which plugin they are talking about. |
27 class PepperBrowserConnection | 26 class PepperBrowserConnection |
28 : public RenderViewObserver, | 27 : public RenderViewObserver, |
29 public RenderViewObserverTracker<PepperBrowserConnection> { | 28 public RenderViewObserverTracker<PepperBrowserConnection> { |
30 public: | 29 public: |
31 typedef base::Callback<void(const std::vector<int>&)> | 30 typedef base::Callback<void(const std::vector<int>&)> |
32 PendingResourceIDCallback; | 31 PendingResourceIDCallback; |
33 typedef base::Callback<void( | 32 typedef base::Callback<void( |
34 const std::vector<ppapi::FileRefDetailedInfo>&)> FileRefGetInfoCallback; | 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; |
35 | 37 |
36 explicit PepperBrowserConnection(RenderView* render_view); | 38 explicit PepperBrowserConnection(RenderView* render_view); |
37 virtual ~PepperBrowserConnection(); | 39 virtual ~PepperBrowserConnection(); |
38 | 40 |
39 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 41 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
40 | 42 |
41 // TODO(teravest): Instead of having separate methods per message, we should | 43 // TODO(teravest): Instead of having separate methods per message, we should |
42 // add generic functionality similar to PluginResource::Call(). | 44 // add generic functionality similar to PluginResource::Call(). |
43 | 45 |
44 // Sends a request to the browser to create ResourceHosts for the given | 46 // Sends a request to the browser to create ResourceHosts for the given |
(...skipping 20 matching lines...) Expand all Loading... |
65 // Called when the renderer deletes an in-process instance. | 67 // Called when the renderer deletes an in-process instance. |
66 void DidDeleteInProcessInstance(PP_Instance instance); | 68 void DidDeleteInProcessInstance(PP_Instance instance); |
67 | 69 |
68 private: | 70 private: |
69 // Message handlers. | 71 // Message handlers. |
70 void OnMsgCreateResourceHostsFromHostReply( | 72 void OnMsgCreateResourceHostsFromHostReply( |
71 int32_t sequence_number, | 73 int32_t sequence_number, |
72 const std::vector<int>& pending_resource_host_ids); | 74 const std::vector<int>& pending_resource_host_ids); |
73 void OnMsgFileRefGetInfoReply( | 75 void OnMsgFileRefGetInfoReply( |
74 int32_t sequence_number, | 76 int32_t sequence_number, |
75 const std::vector<ppapi::FileRefDetailedInfo>& infos); | 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); |
76 | 81 |
77 // Return the next sequence number. | 82 // Return the next sequence number. |
78 int32_t GetNextSequence(); | 83 int32_t GetNextSequence(); |
79 | 84 |
80 // Sequence number to track pending callbacks. | 85 // Sequence number to track pending callbacks. |
81 int32_t next_sequence_number_; | 86 int32_t next_sequence_number_; |
82 | 87 |
83 // Maps a sequence number to the callback to be run. | 88 // Maps a sequence number to the callback to be run. |
84 std::map<int32_t, PendingResourceIDCallback> pending_create_map_; | 89 std::map<int32_t, PendingResourceIDCallback> pending_create_map_; |
85 std::map<int32_t, FileRefGetInfoCallback> get_info_map_; | 90 std::map<int32_t, FileRefGetInfoCallback> get_info_map_; |
86 DISALLOW_COPY_AND_ASSIGN(PepperBrowserConnection); | 91 DISALLOW_COPY_AND_ASSIGN(PepperBrowserConnection); |
87 }; | 92 }; |
88 | 93 |
89 } // namespace content | 94 } // namespace content |
90 | 95 |
91 #endif // CONTENT_RENDERER_PEPPER_PEPPER_BROWSER_CONNECTION_H_ | 96 #endif // CONTENT_RENDERER_PEPPER_PEPPER_BROWSER_CONNECTION_H_ |
OLD | NEW |