Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Side by Side Diff: content/renderer/pepper/pepper_browser_connection.h

Issue 20777009: A few more cleanups to the pepper code. Dispatch IPCs in the sockets implementations directly by ha… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix browsertest Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "ppapi/c/pp_file_info.h" 15 #include "ppapi/c/pp_file_info.h"
15 #include "ppapi/c/pp_instance.h" 16 #include "ppapi/c/pp_instance.h"
16 #include "ppapi/c/pp_resource.h" 17 #include "ppapi/c/pp_resource.h"
17 18
18 namespace content { 19 namespace content {
19 20
20 class PepperHelperImpl;
21
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
26 : public RenderViewObserver,
27 public RenderViewObserverTracker<PepperBrowserConnection> {
27 public: 28 public:
28 typedef base::Callback<void(int)> PendingResourceIDCallback; 29 typedef base::Callback<void(int)> PendingResourceIDCallback;
29 typedef base::Callback<void( 30 typedef base::Callback<void(
30 const std::vector<PP_Resource>&, 31 const std::vector<PP_Resource>&,
31 const std::vector<PP_FileSystemType>&, 32 const std::vector<PP_FileSystemType>&,
32 const std::vector<std::string>&, 33 const std::vector<std::string>&,
33 const std::vector<base::FilePath>&)> FileRefGetInfoCallback; 34 const std::vector<base::FilePath>&)> FileRefGetInfoCallback;
34 35
35 explicit PepperBrowserConnection(PepperHelperImpl* helper); 36 explicit PepperBrowserConnection(RenderView* render_view);
36 virtual ~PepperBrowserConnection(); 37 virtual ~PepperBrowserConnection();
37 38
38 bool OnMessageReceived(const IPC::Message& message); 39 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
39 40
40 // TODO(teravest): Instead of having separate methods per message, we should 41 // TODO(teravest): Instead of having separate methods per message, we should
41 // add generic functionality similar to PluginResource::Call(). 42 // add generic functionality similar to PluginResource::Call().
42 43
43 // 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
44 // |instance| of a plugin identified by |child_process_id|. |callback| will be 45 // |instance| of a plugin identified by |child_process_id|. |callback| will be
45 // run when a reply is received with the pending resource ID. 46 // run when a reply is received with the pending resource ID.
46 void SendBrowserCreate(PP_Instance instance, 47 void SendBrowserCreate(PP_Instance instance,
47 int child_process_id, 48 int child_process_id,
48 const IPC::Message& create_message, 49 const IPC::Message& create_message,
(...skipping 22 matching lines...) Expand all
71 void OnMsgFileRefGetInfoReply( 72 void OnMsgFileRefGetInfoReply(
72 int32_t sequence_number, 73 int32_t sequence_number,
73 const std::vector<PP_Resource>& resources, 74 const std::vector<PP_Resource>& resources,
74 const std::vector<PP_FileSystemType>& types, 75 const std::vector<PP_FileSystemType>& types,
75 const std::vector<std::string>& file_system_url_specs, 76 const std::vector<std::string>& file_system_url_specs,
76 const std::vector<base::FilePath>& external_paths); 77 const std::vector<base::FilePath>& external_paths);
77 78
78 // Return the next sequence number. 79 // Return the next sequence number.
79 int32_t GetNextSequence(); 80 int32_t GetNextSequence();
80 81
81 // The plugin helper that owns us.
82 PepperHelperImpl* helper_;
83
84 // Sequence number to track pending callbacks. 82 // Sequence number to track pending callbacks.
85 int32_t next_sequence_number_; 83 int32_t next_sequence_number_;
86 84
87 // Maps a sequence number to the callback to be run. 85 // Maps a sequence number to the callback to be run.
88 std::map<int32_t, PendingResourceIDCallback> pending_create_map_; 86 std::map<int32_t, PendingResourceIDCallback> pending_create_map_;
89 std::map<int32_t, FileRefGetInfoCallback> get_info_map_; 87 std::map<int32_t, FileRefGetInfoCallback> get_info_map_;
90 DISALLOW_COPY_AND_ASSIGN(PepperBrowserConnection); 88 DISALLOW_COPY_AND_ASSIGN(PepperBrowserConnection);
91 }; 89 };
92 90
93 } // namespace content 91 } // namespace content
94 92
95 #endif // CONTENT_RENDERER_PEPPER_PEPPER_BROWSER_CONNECTION_H_ 93 #endif // CONTENT_RENDERER_PEPPER_PEPPER_BROWSER_CONNECTION_H_
OLDNEW
« no previous file with comments | « content/renderer/pepper/audio_helper.cc ('k') | content/renderer/pepper/pepper_browser_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698