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

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

Issue 15465006: Revert 200932 "Lower the priority of shared workers that aren't ..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
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) {
119 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 118 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
120 DCHECK(resource_context_); 119 DCHECK(resource_context_);
121 process_.reset( 120 process_.reset(
122 new BrowserChildProcessHostImpl(PROCESS_TYPE_WORKER, this)); 121 new BrowserChildProcessHostImpl(PROCESS_TYPE_WORKER, this));
123 } 122 }
124 123
125 WorkerProcessHost::~WorkerProcessHost() { 124 WorkerProcessHost::~WorkerProcessHost() {
126 // If we crashed, tell the RenderViewHosts. 125 // If we crashed, tell the RenderViewHosts.
127 for (Instances::iterator i = instances_.begin(); i != instances_.end(); ++i) { 126 for (Instances::iterator i = instances_.begin(); i != instances_.end(); ++i) {
128 const WorkerDocumentSet::DocumentInfoSet& parents = 127 const WorkerDocumentSet::DocumentInfoSet& parents =
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 if (!i->closed() && i->HasFilter(filter, message.routing_id())) { 311 if (!i->closed() && i->HasFilter(filter, message.routing_id())) {
313 RelayMessage(message, worker_message_filter_, i->worker_route_id()); 312 RelayMessage(message, worker_message_filter_, i->worker_route_id());
314 return true; 313 return true;
315 } 314 }
316 } 315 }
317 316
318 return false; 317 return false;
319 } 318 }
320 319
321 void WorkerProcessHost::OnProcessLaunched() { 320 void WorkerProcessHost::OnProcessLaunched() {
322 process_launched_ = true;
323
324 WorkerServiceImpl::GetInstance()->NotifyWorkerProcessCreated();
325 } 321 }
326 322
327 bool WorkerProcessHost::OnMessageReceived(const IPC::Message& message) { 323 bool WorkerProcessHost::OnMessageReceived(const IPC::Message& message) {
328 bool msg_is_ok = true; 324 bool msg_is_ok = true;
329 bool handled = true; 325 bool handled = true;
330 IPC_BEGIN_MESSAGE_MAP_EX(WorkerProcessHost, message, msg_is_ok) 326 IPC_BEGIN_MESSAGE_MAP_EX(WorkerProcessHost, message, msg_is_ok)
331 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerContextClosed, 327 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerContextClosed,
332 OnWorkerContextClosed) 328 OnWorkerContextClosed)
333 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowDatabase, OnAllowDatabase) 329 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowDatabase, OnAllowDatabase)
334 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowFileSystem, OnAllowFileSystem) 330 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowFileSystem, OnAllowFileSystem)
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 } else { 531 } else {
536 ++i; 532 ++i;
537 } 533 }
538 } 534 }
539 } 535 }
540 536
541 void WorkerProcessHost::TerminateWorker(int worker_route_id) { 537 void WorkerProcessHost::TerminateWorker(int worker_route_id) {
542 Send(new WorkerMsg_TerminateWorkerContext(worker_route_id)); 538 Send(new WorkerMsg_TerminateWorkerContext(worker_route_id));
543 } 539 }
544 540
545 void WorkerProcessHost::SetBackgrounded(bool backgrounded) {
546 process_->SetBackgrounded(backgrounded);
547 }
548
549 const ChildProcessData& WorkerProcessHost::GetData() { 541 const ChildProcessData& WorkerProcessHost::GetData() {
550 return process_->GetData(); 542 return process_->GetData();
551 } 543 }
552 544
553 bool WorkerProcessHost::process_launched() const {
554 return process_launched_;
555 }
556
557 std::vector<std::pair<int, int> > WorkerProcessHost::GetRenderViewIDsForWorker( 545 std::vector<std::pair<int, int> > WorkerProcessHost::GetRenderViewIDsForWorker(
558 int worker_route_id) { 546 int worker_route_id) {
559 std::vector<std::pair<int, int> > result; 547 std::vector<std::pair<int, int> > result;
560 WorkerProcessHost::Instances::const_iterator i; 548 WorkerProcessHost::Instances::const_iterator i;
561 for (i = instances_.begin(); i != instances_.end(); ++i) { 549 for (i = instances_.begin(); i != instances_.end(); ++i) {
562 if (i->worker_route_id() != worker_route_id) 550 if (i->worker_route_id() != worker_route_id)
563 continue; 551 continue;
564 const WorkerDocumentSet::DocumentInfoSet& documents = 552 const WorkerDocumentSet::DocumentInfoSet& documents =
565 i->worker_document_set()->documents(); 553 i->worker_document_set()->documents();
566 for (WorkerDocumentSet::DocumentInfoSet::const_iterator doc = 554 for (WorkerDocumentSet::DocumentInfoSet::const_iterator doc =
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 return false; 691 return false;
704 } 692 }
705 693
706 WorkerProcessHost::WorkerInstance::FilterInfo 694 WorkerProcessHost::WorkerInstance::FilterInfo
707 WorkerProcessHost::WorkerInstance::GetFilter() const { 695 WorkerProcessHost::WorkerInstance::GetFilter() const {
708 DCHECK(NumFilters() == 1); 696 DCHECK(NumFilters() == 1);
709 return *filters_.begin(); 697 return *filters_.begin();
710 } 698 }
711 699
712 } // namespace content 700 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698