| 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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 // being sent to the worker (messages can still be sent from the worker, | 365 // being sent to the worker (messages can still be sent from the worker, |
| 366 // for exception reporting, etc). | 366 // for exception reporting, etc). |
| 367 i->set_closed(true); | 367 i->set_closed(true); |
| 368 break; | 368 break; |
| 369 } | 369 } |
| 370 } | 370 } |
| 371 } | 371 } |
| 372 | 372 |
| 373 void WorkerProcessHost::OnAllowDatabase(int worker_route_id, | 373 void WorkerProcessHost::OnAllowDatabase(int worker_route_id, |
| 374 const GURL& url, | 374 const GURL& url, |
| 375 const string16& name, | 375 const base::string16& name, |
| 376 const string16& display_name, | 376 const base::string16& display_name, |
| 377 unsigned long estimated_size, | 377 unsigned long estimated_size, |
| 378 bool* result) { | 378 bool* result) { |
| 379 *result = GetContentClient()->browser()->AllowWorkerDatabase( | 379 *result = GetContentClient()->browser()->AllowWorkerDatabase( |
| 380 url, name, display_name, estimated_size, resource_context_, | 380 url, name, display_name, estimated_size, resource_context_, |
| 381 GetRenderViewIDsForWorker(worker_route_id)); | 381 GetRenderViewIDsForWorker(worker_route_id)); |
| 382 } | 382 } |
| 383 | 383 |
| 384 void WorkerProcessHost::OnAllowFileSystem(int worker_route_id, | 384 void WorkerProcessHost::OnAllowFileSystem(int worker_route_id, |
| 385 const GURL& url, | 385 const GURL& url, |
| 386 bool* result) { | 386 bool* result) { |
| 387 *result = GetContentClient()->browser()->AllowWorkerFileSystem( | 387 *result = GetContentClient()->browser()->AllowWorkerFileSystem( |
| 388 url, resource_context_, GetRenderViewIDsForWorker(worker_route_id)); | 388 url, resource_context_, GetRenderViewIDsForWorker(worker_route_id)); |
| 389 } | 389 } |
| 390 | 390 |
| 391 void WorkerProcessHost::OnAllowIndexedDB(int worker_route_id, | 391 void WorkerProcessHost::OnAllowIndexedDB(int worker_route_id, |
| 392 const GURL& url, | 392 const GURL& url, |
| 393 const string16& name, | 393 const base::string16& name, |
| 394 bool* result) { | 394 bool* result) { |
| 395 *result = GetContentClient()->browser()->AllowWorkerIndexedDB( | 395 *result = GetContentClient()->browser()->AllowWorkerIndexedDB( |
| 396 url, name, resource_context_, GetRenderViewIDsForWorker(worker_route_id)); | 396 url, name, resource_context_, GetRenderViewIDsForWorker(worker_route_id)); |
| 397 } | 397 } |
| 398 | 398 |
| 399 void WorkerProcessHost::OnForceKillWorkerProcess() { | 399 void WorkerProcessHost::OnForceKillWorkerProcess() { |
| 400 if (process_ && process_launched_) | 400 if (process_ && process_launched_) |
| 401 base::KillProcess( | 401 base::KillProcess( |
| 402 process_->GetData().handle, RESULT_CODE_NORMAL_EXIT, false); | 402 process_->GetData().handle, RESULT_CODE_NORMAL_EXIT, false); |
| 403 else | 403 else |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 *request_context = partition_.url_request_context()->GetURLRequestContext(); | 565 *request_context = partition_.url_request_context()->GetURLRequestContext(); |
| 566 } | 566 } |
| 567 | 567 |
| 568 net::URLRequestContext* WorkerProcessHost::GetRequestContext( | 568 net::URLRequestContext* WorkerProcessHost::GetRequestContext( |
| 569 ResourceType::Type resource_type) { | 569 ResourceType::Type resource_type) { |
| 570 return partition_.url_request_context()->GetURLRequestContext(); | 570 return partition_.url_request_context()->GetURLRequestContext(); |
| 571 } | 571 } |
| 572 | 572 |
| 573 WorkerProcessHost::WorkerInstance::WorkerInstance( | 573 WorkerProcessHost::WorkerInstance::WorkerInstance( |
| 574 const GURL& url, | 574 const GURL& url, |
| 575 const string16& name, | 575 const base::string16& name, |
| 576 int worker_route_id, | 576 int worker_route_id, |
| 577 int parent_process_id, | 577 int parent_process_id, |
| 578 int64 main_resource_appcache_id, | 578 int64 main_resource_appcache_id, |
| 579 ResourceContext* resource_context, | 579 ResourceContext* resource_context, |
| 580 const WorkerStoragePartition& partition) | 580 const WorkerStoragePartition& partition) |
| 581 : url_(url), | 581 : url_(url), |
| 582 closed_(false), | 582 closed_(false), |
| 583 name_(name), | 583 name_(name), |
| 584 worker_route_id_(worker_route_id), | 584 worker_route_id_(worker_route_id), |
| 585 parent_process_id_(parent_process_id), | 585 parent_process_id_(parent_process_id), |
| 586 main_resource_appcache_id_(main_resource_appcache_id), | 586 main_resource_appcache_id_(main_resource_appcache_id), |
| 587 worker_document_set_(new WorkerDocumentSet()), | 587 worker_document_set_(new WorkerDocumentSet()), |
| 588 resource_context_(resource_context), | 588 resource_context_(resource_context), |
| 589 partition_(partition) { | 589 partition_(partition) { |
| 590 DCHECK(resource_context_); | 590 DCHECK(resource_context_); |
| 591 } | 591 } |
| 592 | 592 |
| 593 WorkerProcessHost::WorkerInstance::WorkerInstance( | 593 WorkerProcessHost::WorkerInstance::WorkerInstance( |
| 594 const GURL& url, | 594 const GURL& url, |
| 595 bool shared, | 595 bool shared, |
| 596 const string16& name, | 596 const base::string16& name, |
| 597 ResourceContext* resource_context, | 597 ResourceContext* resource_context, |
| 598 const WorkerStoragePartition& partition) | 598 const WorkerStoragePartition& partition) |
| 599 : url_(url), | 599 : url_(url), |
| 600 closed_(false), | 600 closed_(false), |
| 601 name_(name), | 601 name_(name), |
| 602 worker_route_id_(MSG_ROUTING_NONE), | 602 worker_route_id_(MSG_ROUTING_NONE), |
| 603 parent_process_id_(0), | 603 parent_process_id_(0), |
| 604 main_resource_appcache_id_(0), | 604 main_resource_appcache_id_(0), |
| 605 worker_document_set_(new WorkerDocumentSet()), | 605 worker_document_set_(new WorkerDocumentSet()), |
| 606 resource_context_(resource_context), | 606 resource_context_(resource_context), |
| 607 partition_(partition) { | 607 partition_(partition) { |
| 608 DCHECK(resource_context_); | 608 DCHECK(resource_context_); |
| 609 } | 609 } |
| 610 | 610 |
| 611 WorkerProcessHost::WorkerInstance::~WorkerInstance() { | 611 WorkerProcessHost::WorkerInstance::~WorkerInstance() { |
| 612 } | 612 } |
| 613 | 613 |
| 614 // Compares an instance based on the algorithm in the WebWorkers spec - an | 614 // Compares an instance based on the algorithm in the WebWorkers spec - an |
| 615 // instance matches if the origins of the URLs match, and: | 615 // instance matches if the origins of the URLs match, and: |
| 616 // a) the names are non-empty and equal | 616 // a) the names are non-empty and equal |
| 617 // -or- | 617 // -or- |
| 618 // b) the names are both empty, and the urls are equal | 618 // b) the names are both empty, and the urls are equal |
| 619 bool WorkerProcessHost::WorkerInstance::Matches( | 619 bool WorkerProcessHost::WorkerInstance::Matches( |
| 620 const GURL& match_url, | 620 const GURL& match_url, |
| 621 const string16& match_name, | 621 const base::string16& match_name, |
| 622 const WorkerStoragePartition& partition, | 622 const WorkerStoragePartition& partition, |
| 623 ResourceContext* resource_context) const { | 623 ResourceContext* resource_context) const { |
| 624 // Only match open shared workers. | 624 // Only match open shared workers. |
| 625 if (closed_) | 625 if (closed_) |
| 626 return false; | 626 return false; |
| 627 | 627 |
| 628 // ResourceContext equivalence is being used as a proxy to ensure we only | 628 // ResourceContext equivalence is being used as a proxy to ensure we only |
| 629 // matched shared workers within the same BrowserContext. | 629 // matched shared workers within the same BrowserContext. |
| 630 if (resource_context_ != resource_context) | 630 if (resource_context_ != resource_context) |
| 631 return false; | 631 return false; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 return false; | 700 return false; |
| 701 } | 701 } |
| 702 | 702 |
| 703 WorkerProcessHost::WorkerInstance::FilterInfo | 703 WorkerProcessHost::WorkerInstance::FilterInfo |
| 704 WorkerProcessHost::WorkerInstance::GetFilter() const { | 704 WorkerProcessHost::WorkerInstance::GetFilter() const { |
| 705 DCHECK(NumFilters() == 1); | 705 DCHECK(NumFilters() == 1); |
| 706 return *filters_.begin(); | 706 return *filters_.begin(); |
| 707 } | 707 } |
| 708 | 708 |
| 709 } // namespace content | 709 } // namespace content |
| OLD | NEW |