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

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

Issue 605593002: PPAPI: Support sending browser-hosted resources synchronously Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix content_browsertests 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
33 PendingResourceIDCallback; 39 base::Callback<void(const ppapi::proxy::CompletedBrowserResourceHosts&)>
40 PendingResourceCallback;
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 PendingResourceCallback& callback);
58 void GetAllPendingBrowserHosts(
59 PP_Instance instance,
60 int child_process_id,
61 std::vector<ppapi::proxy::CompletedBrowserResourceHosts>* result);
49 62
50 // Called when the renderer creates an in-process instance. 63 // Called when the renderer creates an in-process instance.
51 void DidCreateInProcessInstance(PP_Instance instance, 64 void DidCreateInProcessInstance(PP_Instance instance,
52 int render_frame_id, 65 int render_frame_id,
53 const GURL& document_url, 66 const GURL& document_url,
54 const GURL& plugin_url); 67 const GURL& plugin_url);
55 68
56 // Called when the renderer deletes an in-process instance. 69 // Called when the renderer deletes an in-process instance.
57 void DidDeleteInProcessInstance(PP_Instance instance); 70 void DidDeleteInProcessInstance(PP_Instance instance);
58 71
59 private: 72 private:
73 struct PendingResource {
74 PendingResource(int child_process_id_param,
75 PP_Instance instance_param,
76 const PendingResourceCallback& callback_param);
77 ~PendingResource();
78 int child_process_id;
79 PP_Instance instance;
80 PendingResourceCallback callback;
81 };
60 // Message handlers. 82 // Message handlers.
61 void OnMsgCreateResourceHostsFromHostReply( 83 void OnMsgCreateResourceHostsFromHostReply(
62 int32_t sequence_number, 84 const ppapi::proxy::CompletedBrowserResourceHosts& hosts);
63 const std::vector<int>& pending_resource_host_ids);
64 85
65 // Return the next sequence number. 86 // Return the next sequence number.
66 int32_t GetNextSequence(); 87 int32_t GetNextSequence();
67 88
68 // Sequence number to track pending callbacks. 89 // Sequence number to track pending callbacks.
69 int32_t next_sequence_number_; 90 int32_t next_sequence_number_;
70 91
71 // Maps a sequence number to the callback to be run. 92 // Maps a sequence number to the callback to be run.
72 std::map<int32_t, PendingResourceIDCallback> pending_create_map_; 93 std::map<int32_t, PendingResource> pending_create_map_;
73 DISALLOW_COPY_AND_ASSIGN(PepperBrowserConnection); 94 DISALLOW_COPY_AND_ASSIGN(PepperBrowserConnection);
74 }; 95 };
75 96
76 } // namespace content 97 } // namespace content
77 98
78 #endif // CONTENT_RENDERER_PEPPER_PEPPER_BROWSER_CONNECTION_H_ 99 #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