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

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

Issue 730603002: PPAPI: Refactor renderer side of browser host creation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge Created 6 years, 1 month 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
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 #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_frame_observer.h" 14 #include "content/public/renderer/render_frame_observer.h"
15 #include "content/public/renderer/render_frame_observer_tracker.h" 15 #include "content/public/renderer/render_frame_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 19
20 class GURL; 20 class GURL;
21 21
22 namespace ppapi {
23 namespace proxy {
24 struct CompletedBrowserResourceHosts;
25 }
26 }
27
22 namespace content { 28 namespace content {
23 29
24 // This class represents a connection from the renderer to the browser for 30 // This class represents a connection from the renderer to the browser for
25 // sending/receiving pepper ResourceHost related messages. When the browser 31 // sending/receiving pepper ResourceHost related messages. When the browser
26 // and renderer communicate about ResourceHosts, they should pass the plugin 32 // and renderer communicate about ResourceHosts, they should pass the plugin
27 // process ID to identify which plugin they are talking about. 33 // process ID to identify which plugin they are talking about.
28 class PepperBrowserConnection 34 class PepperBrowserConnection
29 : public RenderFrameObserver, 35 : public RenderFrameObserver,
30 public RenderFrameObserverTracker<PepperBrowserConnection> { 36 public RenderFrameObserverTracker<PepperBrowserConnection> {
31 public: 37 public:
32 typedef base::Callback<void(const std::vector<int>&)> 38 typedef base::Callback<void(
33 PendingResourceIDCallback; 39 const ppapi::proxy::CompletedBrowserResourceHosts&)>
40 ResourceHostCreationCallback;
34 explicit PepperBrowserConnection(RenderFrame* render_frame); 41 explicit PepperBrowserConnection(RenderFrame* render_frame);
35 ~PepperBrowserConnection() override; 42 ~PepperBrowserConnection() override;
36 43
37 bool OnMessageReceived(const IPC::Message& message) override; 44 bool OnMessageReceived(const IPC::Message& message) override;
38 45
39 // TODO(teravest): Instead of having separate methods per message, we should 46 // TODO(teravest): Instead of having separate methods per message, we should
40 // add generic functionality similar to PluginResource::Call(). 47 // add generic functionality similar to PluginResource::Call().
41 48
42 // Sends a request to the browser to create ResourceHosts for the given 49 // Sends a request to the browser to create ResourceHosts for the given
43 // |instance| of a plugin identified by |child_process_id|. |callback| will be 50 // |instance| of a plugin identified by |child_process_id|. |callback| will be
44 // run when a reply is received with the pending resource IDs. 51 // run when a reply is received with the pending resource IDs.
45 void SendBrowserCreate(PP_Instance instance, 52 // Returns the sequence id for this message, to aid in correlating the
46 int child_process_id, 53 // responses.
47 const std::vector<IPC::Message>& create_messages, 54 int32_t SendBrowserCreate(PP_Instance instance,
48 const PendingResourceIDCallback& callback); 55 int child_process_id,
56 const std::vector<IPC::Message>& create_messages,
57 const ResourceHostCreationCallback& callback);
49 58
50 // Called when the renderer creates an in-process instance. 59 // Called when the renderer creates an in-process instance.
51 void DidCreateInProcessInstance(PP_Instance instance, 60 void DidCreateInProcessInstance(PP_Instance instance,
52 int render_frame_id, 61 int render_frame_id,
53 const GURL& document_url, 62 const GURL& document_url,
54 const GURL& plugin_url); 63 const GURL& plugin_url);
55 64
56 // Called when the renderer deletes an in-process instance. 65 // Called when the renderer deletes an in-process instance.
57 void DidDeleteInProcessInstance(PP_Instance instance); 66 void DidDeleteInProcessInstance(PP_Instance instance);
58 67
59 private: 68 private:
69 struct PendingResource {
70 PendingResource(int child_process_id_param,
71 PP_Instance instance_param,
72 const ResourceHostCreationCallback& callback_param);
73 ~PendingResource();
74 int child_process_id;
75 PP_Instance instance;
76 ResourceHostCreationCallback callback;
77 };
60 // Message handlers. 78 // Message handlers.
61 void OnMsgCreateResourceHostsFromHostReply( 79 void OnMsgCreateResourceHostsFromHostReply(
62 int32_t sequence_number, 80 const ppapi::proxy::CompletedBrowserResourceHosts& hosts);
63 const std::vector<int>& pending_resource_host_ids);
64 81
65 // Return the next sequence number. 82 // Return the next sequence number.
66 int32_t GetNextSequence(); 83 int32_t GetNextSequence();
67 84
68 // Sequence number to track pending callbacks. 85 // Sequence number to track pending callbacks.
69 int32_t next_sequence_number_; 86 int32_t next_sequence_number_;
70 87
71 // Maps a sequence number to the callback to be run. 88 // Maps a sequence number to the callback to be run.
72 std::map<int32_t, PendingResourceIDCallback> pending_create_map_; 89 std::map<int32_t, PendingResource> pending_create_map_;
73 DISALLOW_COPY_AND_ASSIGN(PepperBrowserConnection); 90 DISALLOW_COPY_AND_ASSIGN(PepperBrowserConnection);
74 }; 91 };
75 92
76 } // namespace content 93 } // namespace content
77 94
78 #endif // CONTENT_RENDERER_PEPPER_PEPPER_BROWSER_CONNECTION_H_ 95 #endif // CONTENT_RENDERER_PEPPER_PEPPER_BROWSER_CONNECTION_H_
OLDNEW
« no previous file with comments | « content/renderer/pepper/mock_renderer_ppapi_host.cc ('k') | content/renderer/pepper/pepper_browser_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698