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 #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 16 matching lines...) Expand all Loading... |
27 | 27 |
28 bool PepperBrowserConnection::OnMessageReceived(const IPC::Message& msg) { | 28 bool PepperBrowserConnection::OnMessageReceived(const IPC::Message& msg) { |
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_CreateResourceHostFromHostReply, | 35 IPC_MESSAGE_HANDLER(PpapiHostMsg_CreateResourceHostFromHostReply, |
36 OnMsgCreateResourceHostFromHostReply) | 36 OnMsgCreateResourceHostFromHostReply) |
| 37 IPC_MESSAGE_HANDLER(PpapiHostMsg_FileRef_GetInfoForRendererReply, |
| 38 OnMsgFileRefGetInfoReply) |
37 IPC_MESSAGE_UNHANDLED(handled = false) | 39 IPC_MESSAGE_UNHANDLED(handled = false) |
38 IPC_END_MESSAGE_MAP() | 40 IPC_END_MESSAGE_MAP() |
39 | |
40 return handled; | 41 return handled; |
41 } | 42 } |
42 | 43 |
43 void PepperBrowserConnection::DidCreateInProcessInstance( | 44 void PepperBrowserConnection::DidCreateInProcessInstance( |
44 PP_Instance instance, | 45 PP_Instance instance, |
45 int render_view_id, | 46 int render_view_id, |
46 const GURL& document_url, | 47 const GURL& document_url, |
47 const GURL& plugin_url) { | 48 const GURL& plugin_url) { |
48 Send(new ViewHostMsg_DidCreateInProcessInstance( | 49 Send(new ViewHostMsg_DidCreateInProcessInstance( |
49 instance, | 50 instance, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 if (it != pending_create_map_.end()) { | 95 if (it != pending_create_map_.end()) { |
95 it->second.Run(pending_resource_host_id); | 96 it->second.Run(pending_resource_host_id); |
96 pending_create_map_.erase(it); | 97 pending_create_map_.erase(it); |
97 } else { | 98 } else { |
98 NOTREACHED(); | 99 NOTREACHED(); |
99 } | 100 } |
100 } | 101 } |
101 | 102 |
102 void PepperBrowserConnection::OnMsgFileRefGetInfoReply( | 103 void PepperBrowserConnection::OnMsgFileRefGetInfoReply( |
103 int32_t sequence_number, | 104 int32_t sequence_number, |
104 const std::vector<PP_Resource>& resources, | 105 const std::vector<ppapi::FileRefDetailedInfo>& infos) { |
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 | 106 // Check that the message is destined for the plugin this object is associated |
109 // with. | 107 // with. |
110 std::map<int32_t, FileRefGetInfoCallback>::iterator it = | 108 std::map<int32_t, FileRefGetInfoCallback>::iterator it = |
111 get_info_map_.find(sequence_number); | 109 get_info_map_.find(sequence_number); |
112 if (it != get_info_map_.end()) { | 110 if (it != get_info_map_.end()) { |
113 FileRefGetInfoCallback callback = it->second; | 111 FileRefGetInfoCallback callback = it->second; |
114 get_info_map_.erase(it); | 112 get_info_map_.erase(it); |
115 callback.Run(resources, types, file_system_url_specs, external_paths); | 113 callback.Run(infos); |
116 } else { | 114 } else { |
117 NOTREACHED(); | 115 NOTREACHED(); |
118 } | 116 } |
119 } | 117 } |
120 | 118 |
121 int32_t PepperBrowserConnection::GetNextSequence() { | 119 int32_t PepperBrowserConnection::GetNextSequence() { |
122 // Return the value with wraparound, making sure we don't make a sequence | 120 // Return the value with wraparound, making sure we don't make a sequence |
123 // number with a 0 ID. Note that signed wraparound is undefined in C++ so we | 121 // number with a 0 ID. Note that signed wraparound is undefined in C++ so we |
124 // manually check. | 122 // manually check. |
125 int32_t ret = next_sequence_number_; | 123 int32_t ret = next_sequence_number_; |
126 if (next_sequence_number_ == std::numeric_limits<int32_t>::max()) | 124 if (next_sequence_number_ == std::numeric_limits<int32_t>::max()) |
127 next_sequence_number_ = 1; // Skip 0 which is invalid. | 125 next_sequence_number_ = 1; // Skip 0 which is invalid. |
128 else | 126 else |
129 next_sequence_number_++; | 127 next_sequence_number_++; |
130 return ret; | 128 return ret; |
131 } | 129 } |
132 | 130 |
133 } // namespace content | 131 } // namespace content |
OLD | NEW |