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

Side by Side Diff: trunk/src/content/renderer/pepper/pepper_browser_connection.cc

Issue 23647008: Revert 221284 "Pepper: Move FileRef to the "new" resource proxy." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 3 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 #include "content/renderer/pepper/pepper_browser_connection.h" 5 #include "content/renderer/pepper/pepper_browser_connection.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "content/common/view_messages.h" 10 #include "content/common/view_messages.h"
(...skipping 18 matching lines...) Expand all
29 // Check if the message is an in-process reply. 29 // Check if the message is an in-process reply.
30 if (PepperInProcessRouter::OnPluginMsgReceived(msg)) 30 if (PepperInProcessRouter::OnPluginMsgReceived(msg))
31 return true; 31 return true;
32 32
33 bool handled = true; 33 bool handled = true;
34 IPC_BEGIN_MESSAGE_MAP(PepperBrowserConnection, msg) 34 IPC_BEGIN_MESSAGE_MAP(PepperBrowserConnection, msg)
35 IPC_MESSAGE_HANDLER(PpapiHostMsg_CreateResourceHostsFromHostReply, 35 IPC_MESSAGE_HANDLER(PpapiHostMsg_CreateResourceHostsFromHostReply,
36 OnMsgCreateResourceHostsFromHostReply) 36 OnMsgCreateResourceHostsFromHostReply)
37 IPC_MESSAGE_UNHANDLED(handled = false) 37 IPC_MESSAGE_UNHANDLED(handled = false)
38 IPC_END_MESSAGE_MAP() 38 IPC_END_MESSAGE_MAP()
39
39 return handled; 40 return handled;
40 } 41 }
41 42
42 void PepperBrowserConnection::DidCreateInProcessInstance( 43 void PepperBrowserConnection::DidCreateInProcessInstance(
43 PP_Instance instance, 44 PP_Instance instance,
44 int render_view_id, 45 int render_view_id,
45 const GURL& document_url, 46 const GURL& document_url,
46 const GURL& plugin_url) { 47 const GURL& plugin_url) {
47 Send(new ViewHostMsg_DidCreateInProcessInstance( 48 Send(new ViewHostMsg_DidCreateInProcessInstance(
48 instance, 49 instance,
(...skipping 17 matching lines...) Expand all
66 pending_create_map_[sequence_number] = callback; 67 pending_create_map_[sequence_number] = callback;
67 ppapi::proxy::ResourceMessageCallParams params(0, sequence_number); 68 ppapi::proxy::ResourceMessageCallParams params(0, sequence_number);
68 Send(new PpapiHostMsg_CreateResourceHostsFromHost( 69 Send(new PpapiHostMsg_CreateResourceHostsFromHost(
69 routing_id(), 70 routing_id(),
70 child_process_id, 71 child_process_id,
71 params, 72 params,
72 instance, 73 instance,
73 nested_msgs)); 74 nested_msgs));
74 } 75 }
75 76
77 void PepperBrowserConnection::SendBrowserFileRefGetInfo(
78 int child_process_id,
79 const std::vector<PP_Resource>& resources,
80 const FileRefGetInfoCallback& callback) {
81 int32_t sequence_number = GetNextSequence();
82 get_info_map_[sequence_number] = callback;
83 Send(new PpapiHostMsg_FileRef_GetInfoForRenderer(
84 routing_id(), child_process_id, sequence_number, resources));
85 }
86
76 void PepperBrowserConnection::OnMsgCreateResourceHostsFromHostReply( 87 void PepperBrowserConnection::OnMsgCreateResourceHostsFromHostReply(
77 int32_t sequence_number, 88 int32_t sequence_number,
78 const std::vector<int>& pending_resource_host_ids) { 89 const std::vector<int>& pending_resource_host_ids) {
79 // Check that the message is destined for the plugin this object is associated 90 // Check that the message is destined for the plugin this object is associated
80 // with. 91 // with.
81 std::map<int32_t, PendingResourceIDCallback>::iterator it = 92 std::map<int32_t, PendingResourceIDCallback>::iterator it =
82 pending_create_map_.find(sequence_number); 93 pending_create_map_.find(sequence_number);
83 if (it != pending_create_map_.end()) { 94 if (it != pending_create_map_.end()) {
84 it->second.Run(pending_resource_host_ids); 95 it->second.Run(pending_resource_host_ids);
85 pending_create_map_.erase(it); 96 pending_create_map_.erase(it);
86 } else { 97 } else {
87 NOTREACHED(); 98 NOTREACHED();
88 } 99 }
89 } 100 }
90 101
102 void PepperBrowserConnection::OnMsgFileRefGetInfoReply(
103 int32_t sequence_number,
104 const std::vector<PP_Resource>& resources,
105 const std::vector<PP_FileSystemType>& types,
106 const std::vector<std::string>& file_system_url_specs,
107 const std::vector<base::FilePath>& external_paths) {
108 // Check that the message is destined for the plugin this object is associated
109 // with.
110 std::map<int32_t, FileRefGetInfoCallback>::iterator it =
111 get_info_map_.find(sequence_number);
112 if (it != get_info_map_.end()) {
113 FileRefGetInfoCallback callback = it->second;
114 get_info_map_.erase(it);
115 callback.Run(resources, types, file_system_url_specs, external_paths);
116 } else {
117 NOTREACHED();
118 }
119 }
120
91 int32_t PepperBrowserConnection::GetNextSequence() { 121 int32_t PepperBrowserConnection::GetNextSequence() {
92 // Return the value with wraparound, making sure we don't make a sequence 122 // Return the value with wraparound, making sure we don't make a sequence
93 // number with a 0 ID. Note that signed wraparound is undefined in C++ so we 123 // number with a 0 ID. Note that signed wraparound is undefined in C++ so we
94 // manually check. 124 // manually check.
95 int32_t ret = next_sequence_number_; 125 int32_t ret = next_sequence_number_;
96 if (next_sequence_number_ == std::numeric_limits<int32_t>::max()) 126 if (next_sequence_number_ == std::numeric_limits<int32_t>::max())
97 next_sequence_number_ = 1; // Skip 0 which is invalid. 127 next_sequence_number_ = 1; // Skip 0 which is invalid.
98 else 128 else
99 next_sequence_number_++; 129 next_sequence_number_++;
100 return ret; 130 return ret;
101 } 131 }
102 132
103 } // namespace content 133 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698