| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/shared_worker/shared_worker_host.h" | 5 #include "content/browser/shared_worker/shared_worker_host.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "content/browser/devtools/embedded_worker_devtools_manager.h" | 8 #include "content/browser/devtools/embedded_worker_devtools_manager.h" |
| 9 #include "content/browser/frame_host/render_frame_host_delegate.h" | 9 #include "content/browser/frame_host/render_frame_host_delegate.h" |
| 10 #include "content/browser/frame_host/render_frame_host_impl.h" | 10 #include "content/browser/frame_host/render_frame_host_impl.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 worker_process_id, worker_route_id); | 56 worker_process_id, worker_route_id); |
| 57 } | 57 } |
| 58 | 58 |
| 59 } // namespace | 59 } // namespace |
| 60 | 60 |
| 61 SharedWorkerHost::SharedWorkerHost(SharedWorkerInstance* instance, | 61 SharedWorkerHost::SharedWorkerHost(SharedWorkerInstance* instance, |
| 62 SharedWorkerMessageFilter* filter, | 62 SharedWorkerMessageFilter* filter, |
| 63 int worker_route_id) | 63 int worker_route_id) |
| 64 : instance_(instance), | 64 : instance_(instance), |
| 65 worker_document_set_(new WorkerDocumentSet()), | 65 worker_document_set_(new WorkerDocumentSet()), |
| 66 weak_factory_(this), |
| 66 container_render_filter_(filter), | 67 container_render_filter_(filter), |
| 67 worker_process_id_(filter->render_process_id()), | 68 worker_process_id_(filter->render_process_id()), |
| 68 worker_route_id_(worker_route_id), | 69 worker_route_id_(worker_route_id), |
| 69 load_failed_(false), | 70 load_failed_(false), |
| 70 closed_(false), | 71 closed_(false), |
| 71 creation_time_(base::TimeTicks::Now()) { | 72 creation_time_(base::TimeTicks::Now()) { |
| 72 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 73 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 73 } | 74 } |
| 74 | 75 |
| 75 SharedWorkerHost::~SharedWorkerHost() { | 76 SharedWorkerHost::~SharedWorkerHost() { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 *result = GetContentClient()->browser()->AllowWorkerDatabase( | 215 *result = GetContentClient()->browser()->AllowWorkerDatabase( |
| 215 url, | 216 url, |
| 216 name, | 217 name, |
| 217 display_name, | 218 display_name, |
| 218 estimated_size, | 219 estimated_size, |
| 219 instance_->resource_context(), | 220 instance_->resource_context(), |
| 220 GetRenderFrameIDsForWorker()); | 221 GetRenderFrameIDsForWorker()); |
| 221 } | 222 } |
| 222 | 223 |
| 223 void SharedWorkerHost::AllowFileSystem(const GURL& url, | 224 void SharedWorkerHost::AllowFileSystem(const GURL& url, |
| 224 bool* result) { | 225 scoped_ptr<IPC::Message> reply_msg) { |
| 225 if (!instance_) | 226 if (!instance_) |
| 226 return; | 227 return; |
| 227 *result = GetContentClient()->browser()->AllowWorkerFileSystem( | 228 GetContentClient()->browser()->AllowWorkerFileSystem( |
| 228 url, instance_->resource_context(), GetRenderFrameIDsForWorker()); | 229 url, |
| 230 instance_->resource_context(), |
| 231 GetRenderFrameIDsForWorker(), |
| 232 base::Bind(&SharedWorkerHost::AllowFileSystemResponse, |
| 233 weak_factory_.GetWeakPtr(), |
| 234 base::Passed(&reply_msg))); |
| 235 } |
| 236 |
| 237 void SharedWorkerHost::AllowFileSystemResponse( |
| 238 scoped_ptr<IPC::Message> reply_msg, |
| 239 bool allowed) { |
| 240 WorkerProcessHostMsg_RequestFileSystemAccessSync::WriteReplyParams( |
| 241 reply_msg.get(), |
| 242 allowed); |
| 243 Send(reply_msg.release()); |
| 229 } | 244 } |
| 230 | 245 |
| 231 void SharedWorkerHost::AllowIndexedDB(const GURL& url, | 246 void SharedWorkerHost::AllowIndexedDB(const GURL& url, |
| 232 const base::string16& name, | 247 const base::string16& name, |
| 233 bool* result) { | 248 bool* result) { |
| 234 if (!instance_) | 249 if (!instance_) |
| 235 return; | 250 return; |
| 236 *result = GetContentClient()->browser()->AllowWorkerIndexedDB( | 251 *result = GetContentClient()->browser()->AllowWorkerIndexedDB( |
| 237 url, name, instance_->resource_context(), GetRenderFrameIDsForWorker()); | 252 url, name, instance_->resource_context(), GetRenderFrameIDsForWorker()); |
| 238 } | 253 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 int message_port_id) { | 342 int message_port_id) { |
| 328 for (FilterList::iterator i = filters_.begin(); i != filters_.end(); ++i) { | 343 for (FilterList::iterator i = filters_.begin(); i != filters_.end(); ++i) { |
| 329 if (i->filter() == filter && i->route_id() == route_id) { | 344 if (i->filter() == filter && i->route_id() == route_id) { |
| 330 i->set_message_port_id(message_port_id); | 345 i->set_message_port_id(message_port_id); |
| 331 return; | 346 return; |
| 332 } | 347 } |
| 333 } | 348 } |
| 334 } | 349 } |
| 335 | 350 |
| 336 } // namespace content | 351 } // namespace content |
| OLD | NEW |