OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/ppapi_plugin_process_host.h" | 5 #include "content/browser/ppapi_plugin_process_host.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 }; | 63 }; |
64 | 64 |
65 PpapiPluginProcessHost::~PpapiPluginProcessHost() { | 65 PpapiPluginProcessHost::~PpapiPluginProcessHost() { |
66 DVLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "") | 66 DVLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "") |
67 << "~PpapiPluginProcessHost()"; | 67 << "~PpapiPluginProcessHost()"; |
68 CancelRequests(); | 68 CancelRequests(); |
69 } | 69 } |
70 | 70 |
71 PpapiPluginProcessHost* PpapiPluginProcessHost::CreatePluginHost( | 71 PpapiPluginProcessHost* PpapiPluginProcessHost::CreatePluginHost( |
72 const content::PepperPluginInfo& info, | 72 const content::PepperPluginInfo& info, |
| 73 const FilePath& data_directory_path, |
73 net::HostResolver* host_resolver) { | 74 net::HostResolver* host_resolver) { |
74 PpapiPluginProcessHost* plugin_host = | 75 PpapiPluginProcessHost* plugin_host = |
75 new PpapiPluginProcessHost(host_resolver); | 76 new PpapiPluginProcessHost(info.name, data_directory_path, host_resolver); |
76 if (plugin_host->Init(info)) | 77 if (plugin_host->Init(info)) |
77 return plugin_host; | 78 return plugin_host; |
78 | 79 |
79 NOTREACHED(); // Init is not expected to fail. | 80 NOTREACHED(); // Init is not expected to fail. |
80 return NULL; | 81 return NULL; |
81 } | 82 } |
82 | 83 |
83 PpapiPluginProcessHost* PpapiPluginProcessHost::CreateBrokerHost( | 84 PpapiPluginProcessHost* PpapiPluginProcessHost::CreateBrokerHost( |
84 const content::PepperPluginInfo& info) { | 85 const content::PepperPluginInfo& info) { |
85 PpapiPluginProcessHost* plugin_host = | 86 PpapiPluginProcessHost* plugin_host = |
(...skipping 15 matching lines...) Expand all Loading... |
101 // this "open channel" request into a queue of requests that will | 102 // this "open channel" request into a queue of requests that will |
102 // be run once the channel is open. | 103 // be run once the channel is open. |
103 pending_requests_.push_back(client); | 104 pending_requests_.push_back(client); |
104 return; | 105 return; |
105 } | 106 } |
106 | 107 |
107 // We already have an open channel, send a request right away to plugin. | 108 // We already have an open channel, send a request right away to plugin. |
108 RequestPluginChannel(client); | 109 RequestPluginChannel(client); |
109 } | 110 } |
110 | 111 |
111 PpapiPluginProcessHost::PpapiPluginProcessHost(net::HostResolver* host_resolver) | 112 PpapiPluginProcessHost::PpapiPluginProcessHost( |
112 : filter_(new PepperMessageFilter(PepperMessageFilter::PLUGIN, | 113 const std::string& plugin_name, |
113 host_resolver)), | 114 const FilePath& profile_data_directory, |
114 network_observer_(new PluginNetworkObserver(this)), | 115 net::HostResolver* host_resolver) |
| 116 : network_observer_(new PluginNetworkObserver(this)), |
| 117 profile_data_directory_(profile_data_directory), |
115 is_broker_(false) { | 118 is_broker_(false) { |
116 process_.reset(new BrowserChildProcessHostImpl( | 119 process_.reset(new BrowserChildProcessHostImpl( |
117 content::PROCESS_TYPE_PPAPI_PLUGIN, this)); | 120 content::PROCESS_TYPE_PPAPI_PLUGIN, this)); |
| 121 |
| 122 filter_ = new PepperMessageFilter( |
| 123 PepperMessageFilter::PLUGIN, host_resolver); |
| 124 |
| 125 file_filter_ = new PepperTrustedFileMessageFilter( |
| 126 process_->GetData().id, plugin_name, profile_data_directory); |
| 127 |
118 process_->GetHost()->AddFilter(filter_.get()); | 128 process_->GetHost()->AddFilter(filter_.get()); |
| 129 process_->GetHost()->AddFilter(file_filter_.get()); |
119 } | 130 } |
120 | 131 |
121 PpapiPluginProcessHost::PpapiPluginProcessHost() | 132 PpapiPluginProcessHost::PpapiPluginProcessHost() |
122 : is_broker_(true) { | 133 : is_broker_(true) { |
123 process_.reset(new BrowserChildProcessHostImpl( | 134 process_.reset(new BrowserChildProcessHostImpl( |
124 content::PROCESS_TYPE_PPAPI_BROKER, this)); | 135 content::PROCESS_TYPE_PPAPI_BROKER, this)); |
125 } | 136 } |
126 | 137 |
127 bool PpapiPluginProcessHost::Init(const content::PepperPluginInfo& info) { | 138 bool PpapiPluginProcessHost::Init(const content::PepperPluginInfo& info) { |
128 plugin_path_ = info.path; | 139 plugin_path_ = info.path; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 if (sent_requests_.empty()) | 286 if (sent_requests_.empty()) |
276 return; | 287 return; |
277 | 288 |
278 // All requests should be processed FIFO, so the next item in the | 289 // All requests should be processed FIFO, so the next item in the |
279 // sent_requests_ queue should be the one that the plugin just created. | 290 // sent_requests_ queue should be the one that the plugin just created. |
280 Client* client = sent_requests_.front(); | 291 Client* client = sent_requests_.front(); |
281 sent_requests_.pop(); | 292 sent_requests_.pop(); |
282 | 293 |
283 client->OnPpapiChannelOpened(channel_handle, process_->GetData().id); | 294 client->OnPpapiChannelOpened(channel_handle, process_->GetData().id); |
284 } | 295 } |
OLD | NEW |