Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Side by Side Diff: content/browser/worker_host/worker_process_host.cc

Issue 14137016: Lower the priority of shared workers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes from review. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 RenderViewHostImpl* host = 107 RenderViewHostImpl* host =
108 RenderViewHostImpl::FromID(render_process_unique_id, render_view_id); 108 RenderViewHostImpl::FromID(render_process_unique_id, render_view_id);
109 if (host) 109 if (host)
110 host->GetDelegate()->WorkerCrashed(); 110 host->GetDelegate()->WorkerCrashed();
111 } 111 }
112 112
113 WorkerProcessHost::WorkerProcessHost( 113 WorkerProcessHost::WorkerProcessHost(
114 ResourceContext* resource_context, 114 ResourceContext* resource_context,
115 const WorkerStoragePartition& partition) 115 const WorkerStoragePartition& partition)
116 : resource_context_(resource_context), 116 : resource_context_(resource_context),
117 partition_(partition) { 117 partition_(partition),
118 process_launched_(false) {
118 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 119 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
119 DCHECK(resource_context_); 120 DCHECK(resource_context_);
120 process_.reset( 121 process_.reset(
121 new BrowserChildProcessHostImpl(PROCESS_TYPE_WORKER, this)); 122 new BrowserChildProcessHostImpl(PROCESS_TYPE_WORKER, this));
122 } 123 }
123 124
124 WorkerProcessHost::~WorkerProcessHost() { 125 WorkerProcessHost::~WorkerProcessHost() {
125 // If we crashed, tell the RenderViewHosts. 126 // If we crashed, tell the RenderViewHosts.
126 for (Instances::iterator i = instances_.begin(); i != instances_.end(); ++i) { 127 for (Instances::iterator i = instances_.begin(); i != instances_.end(); ++i) {
127 const WorkerDocumentSet::DocumentInfoSet& parents = 128 const WorkerDocumentSet::DocumentInfoSet& parents =
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 if (!i->closed() && i->HasFilter(filter, message.routing_id())) { 312 if (!i->closed() && i->HasFilter(filter, message.routing_id())) {
312 RelayMessage(message, worker_message_filter_, i->worker_route_id()); 313 RelayMessage(message, worker_message_filter_, i->worker_route_id());
313 return true; 314 return true;
314 } 315 }
315 } 316 }
316 317
317 return false; 318 return false;
318 } 319 }
319 320
320 void WorkerProcessHost::OnProcessLaunched() { 321 void WorkerProcessHost::OnProcessLaunched() {
322 process_launched_ = true;
323
324 WorkerServiceImpl::GetInstance()->NotifyWorkerProcessCreated();
321 } 325 }
322 326
323 bool WorkerProcessHost::OnMessageReceived(const IPC::Message& message) { 327 bool WorkerProcessHost::OnMessageReceived(const IPC::Message& message) {
324 bool msg_is_ok = true; 328 bool msg_is_ok = true;
325 bool handled = true; 329 bool handled = true;
326 IPC_BEGIN_MESSAGE_MAP_EX(WorkerProcessHost, message, msg_is_ok) 330 IPC_BEGIN_MESSAGE_MAP_EX(WorkerProcessHost, message, msg_is_ok)
327 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerContextClosed, 331 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerContextClosed,
328 OnWorkerContextClosed) 332 OnWorkerContextClosed)
329 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowDatabase, OnAllowDatabase) 333 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowDatabase, OnAllowDatabase)
330 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowFileSystem, OnAllowFileSystem) 334 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowFileSystem, OnAllowFileSystem)
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 } else { 535 } else {
532 ++i; 536 ++i;
533 } 537 }
534 } 538 }
535 } 539 }
536 540
537 void WorkerProcessHost::TerminateWorker(int worker_route_id) { 541 void WorkerProcessHost::TerminateWorker(int worker_route_id) {
538 Send(new WorkerMsg_TerminateWorkerContext(worker_route_id)); 542 Send(new WorkerMsg_TerminateWorkerContext(worker_route_id));
539 } 543 }
540 544
545 void WorkerProcessHost::SetBackgrounded(bool backgrounded) {
546 process_->SetBackgrounded(backgrounded);
547 }
548
541 const ChildProcessData& WorkerProcessHost::GetData() { 549 const ChildProcessData& WorkerProcessHost::GetData() {
542 return process_->GetData(); 550 return process_->GetData();
543 } 551 }
544 552
545 std::vector<std::pair<int, int> > WorkerProcessHost::GetRenderViewIDsForWorker( 553 std::vector<std::pair<int, int> > WorkerProcessHost::GetRenderViewIDsForWorker(
546 int worker_route_id) { 554 int worker_route_id) {
547 std::vector<std::pair<int, int> > result; 555 std::vector<std::pair<int, int> > result;
548 WorkerProcessHost::Instances::const_iterator i; 556 WorkerProcessHost::Instances::const_iterator i;
549 for (i = instances_.begin(); i != instances_.end(); ++i) { 557 for (i = instances_.begin(); i != instances_.end(); ++i) {
550 if (i->worker_route_id() != worker_route_id) 558 if (i->worker_route_id() != worker_route_id)
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 return false; 699 return false;
692 } 700 }
693 701
694 WorkerProcessHost::WorkerInstance::FilterInfo 702 WorkerProcessHost::WorkerInstance::FilterInfo
695 WorkerProcessHost::WorkerInstance::GetFilter() const { 703 WorkerProcessHost::WorkerInstance::GetFilter() const {
696 DCHECK(NumFilters() == 1); 704 DCHECK(NumFilters() == 1);
697 return *filters_.begin(); 705 return *filters_.begin();
698 } 706 }
699 707
700 } // namespace content 708 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/worker_host/worker_process_host.h ('k') | content/browser/worker_host/worker_service_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698