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