| 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/worker_host/worker_process_host.h" | 5 #include "content/browser/worker_host/worker_process_host.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 worker_process_id); | 134 worker_process_id); |
| 135 } | 135 } |
| 136 | 136 |
| 137 } // namespace | 137 } // namespace |
| 138 | 138 |
| 139 WorkerProcessHost::WorkerProcessHost( | 139 WorkerProcessHost::WorkerProcessHost( |
| 140 ResourceContext* resource_context, | 140 ResourceContext* resource_context, |
| 141 const WorkerStoragePartition& partition) | 141 const WorkerStoragePartition& partition) |
| 142 : resource_context_(resource_context), | 142 : resource_context_(resource_context), |
| 143 partition_(partition), | 143 partition_(partition), |
| 144 process_launched_(false) { | 144 process_launched_(false), |
| 145 weak_factory_(this) { |
| 145 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 146 DCHECK(resource_context_); | 147 DCHECK(resource_context_); |
| 147 process_.reset( | 148 process_.reset( |
| 148 new BrowserChildProcessHostImpl(PROCESS_TYPE_WORKER, this)); | 149 new BrowserChildProcessHostImpl(PROCESS_TYPE_WORKER, this)); |
| 149 } | 150 } |
| 150 | 151 |
| 151 WorkerProcessHost::~WorkerProcessHost() { | 152 WorkerProcessHost::~WorkerProcessHost() { |
| 152 // If we crashed, tell the RenderViewHosts. | 153 // If we crashed, tell the RenderViewHosts. |
| 153 for (Instances::iterator i = instances_.begin(); i != instances_.end(); ++i) { | 154 for (Instances::iterator i = instances_.begin(); i != instances_.end(); ++i) { |
| 154 if (!i->load_failed()) { | 155 if (!i->load_failed()) { |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 OnWorkerContextClosed) | 379 OnWorkerContextClosed) |
| 379 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerContextDestroyed, | 380 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerContextDestroyed, |
| 380 OnWorkerContextDestroyed) | 381 OnWorkerContextDestroyed) |
| 381 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerScriptLoaded, | 382 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerScriptLoaded, |
| 382 OnWorkerScriptLoaded) | 383 OnWorkerScriptLoaded) |
| 383 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerScriptLoadFailed, | 384 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerScriptLoadFailed, |
| 384 OnWorkerScriptLoadFailed) | 385 OnWorkerScriptLoadFailed) |
| 385 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerConnected, | 386 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerConnected, |
| 386 OnWorkerConnected) | 387 OnWorkerConnected) |
| 387 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowDatabase, OnAllowDatabase) | 388 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowDatabase, OnAllowDatabase) |
| 388 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_RequestFileSystemAccessSync, | 389 IPC_MESSAGE_HANDLER_DELAY_REPLY( |
| 389 OnRequestFileSystemAccessSync) | 390 WorkerProcessHostMsg_RequestFileSystemAccessSync, |
| 391 OnRequestFileSystemAccess) |
| 390 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowIndexedDB, OnAllowIndexedDB) | 392 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowIndexedDB, OnAllowIndexedDB) |
| 391 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_ForceKillWorker, | 393 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_ForceKillWorker, |
| 392 OnForceKillWorkerProcess) | 394 OnForceKillWorkerProcess) |
| 393 IPC_MESSAGE_UNHANDLED(handled = false) | 395 IPC_MESSAGE_UNHANDLED(handled = false) |
| 394 IPC_END_MESSAGE_MAP() | 396 IPC_END_MESSAGE_MAP() |
| 395 | 397 |
| 396 return handled; | 398 return handled; |
| 397 } | 399 } |
| 398 | 400 |
| 399 // Sent to notify the browser process when a worker context invokes close(), so | 401 // Sent to notify the browser process when a worker context invokes close(), so |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 const GURL& url, | 467 const GURL& url, |
| 466 const base::string16& name, | 468 const base::string16& name, |
| 467 const base::string16& display_name, | 469 const base::string16& display_name, |
| 468 unsigned long estimated_size, | 470 unsigned long estimated_size, |
| 469 bool* result) { | 471 bool* result) { |
| 470 *result = GetContentClient()->browser()->AllowWorkerDatabase( | 472 *result = GetContentClient()->browser()->AllowWorkerDatabase( |
| 471 url, name, display_name, estimated_size, resource_context_, | 473 url, name, display_name, estimated_size, resource_context_, |
| 472 GetRenderFrameIDsForWorker(worker_route_id)); | 474 GetRenderFrameIDsForWorker(worker_route_id)); |
| 473 } | 475 } |
| 474 | 476 |
| 475 void WorkerProcessHost::OnRequestFileSystemAccessSync(int worker_route_id, | 477 void WorkerProcessHost::OnRequestFileSystemAccess(int worker_route_id, |
| 476 const GURL& url, | 478 const GURL& url, |
| 477 bool* result) { | 479 IPC::Message* reply_msg) { |
| 478 *result = GetContentClient()->browser()->AllowWorkerFileSystem( | 480 GetContentClient()->browser()->AllowWorkerFileSystem( |
| 479 url, resource_context_, GetRenderFrameIDsForWorker(worker_route_id)); | 481 url, |
| 482 resource_context_, |
| 483 GetRenderFrameIDsForWorker(worker_route_id), |
| 484 base::Bind(&WorkerProcessHost::OnRequestFileSystemAccessResponse, |
| 485 weak_factory_.GetWeakPtr(), |
| 486 base::Passed(scoped_ptr<IPC::Message>(reply_msg)))); |
| 487 } |
| 488 |
| 489 void WorkerProcessHost::OnRequestFileSystemAccessResponse( |
| 490 scoped_ptr<IPC::Message> reply_msg, |
| 491 bool allowed) { |
| 492 WorkerProcessHostMsg_RequestFileSystemAccessSync::WriteReplyParams( |
| 493 reply_msg.get(), |
| 494 allowed); |
| 495 Send(reply_msg.release()); |
| 480 } | 496 } |
| 481 | 497 |
| 482 void WorkerProcessHost::OnAllowIndexedDB(int worker_route_id, | 498 void WorkerProcessHost::OnAllowIndexedDB(int worker_route_id, |
| 483 const GURL& url, | 499 const GURL& url, |
| 484 const base::string16& name, | 500 const base::string16& name, |
| 485 bool* result) { | 501 bool* result) { |
| 486 *result = GetContentClient()->browser()->AllowWorkerIndexedDB( | 502 *result = GetContentClient()->browser()->AllowWorkerIndexedDB( |
| 487 url, name, resource_context_, | 503 url, name, resource_context_, |
| 488 GetRenderFrameIDsForWorker(worker_route_id)); | 504 GetRenderFrameIDsForWorker(worker_route_id)); |
| 489 } | 505 } |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 return false; | 836 return false; |
| 821 } | 837 } |
| 822 | 838 |
| 823 WorkerProcessHost::WorkerInstance::FilterInfo | 839 WorkerProcessHost::WorkerInstance::FilterInfo |
| 824 WorkerProcessHost::WorkerInstance::GetFilter() const { | 840 WorkerProcessHost::WorkerInstance::GetFilter() const { |
| 825 DCHECK(NumFilters() == 1); | 841 DCHECK(NumFilters() == 1); |
| 826 return *filters_.begin(); | 842 return *filters_.begin(); |
| 827 } | 843 } |
| 828 | 844 |
| 829 } // namespace content | 845 } // namespace content |
| OLD | NEW |