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

Side by Side Diff: content/browser/service_worker/embedded_worker_instance.cc

Issue 140743012: Start EmbeddedWorker during registration - take 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/service_worker/embedded_worker_instance.h" 5 #include "content/browser/service_worker/embedded_worker_instance.h"
6 6
7 #include "content/browser/service_worker/embedded_worker_registry.h" 7 #include "content/browser/service_worker/embedded_worker_registry.h"
8 #include "content/common/service_worker/embedded_worker_messages.h" 8 #include "content/common/service_worker/embedded_worker_messages.h"
9 #include "ipc/ipc_message.h" 9 #include "ipc/ipc_message.h"
10 #include "url/gurl.h" 10 #include "url/gurl.h"
11 11
12 namespace content { 12 namespace content {
13 13
14 EmbeddedWorkerInstance::~EmbeddedWorkerInstance() { 14 EmbeddedWorkerInstance::~EmbeddedWorkerInstance() {
15 registry_->RemoveWorker(process_id_, embedded_worker_id_); 15 registry_->RemoveWorker(process_id_, embedded_worker_id_);
16 } 16 }
17 17
18 bool EmbeddedWorkerInstance::Start( 18 bool EmbeddedWorkerInstance::Start(
19 int64 service_worker_version_id, 19 int64 service_worker_version_id,
20 const GURL& script_url, 20 const GURL& script_url,
21 const IPC::Message& initialize_message) { 21 const IPC::Message& initialize_message) {
22 LOG(ERROR) << "Starting EmbeddedWorkerInstance";
22 DCHECK(status_ == STOPPED); 23 DCHECK(status_ == STOPPED);
23 if (!ChooseProcess()) 24 if (!ChooseProcess()) {
25 LOG(ERROR) << "Couldnl't find process to run worker..";
24 return false; 26 return false;
27 }
25 status_ = STARTING; 28 status_ = STARTING;
26 bool success = registry_->StartWorker( 29 bool success = registry_->StartWorker(
27 process_id_, 30 process_id_,
28 embedded_worker_id_, 31 embedded_worker_id_,
29 service_worker_version_id, 32 service_worker_version_id,
30 script_url, 33 script_url,
31 initialize_message); 34 initialize_message);
32 if (!success) { 35 if (!success) {
33 status_ = STOPPED; 36 status_ = STOPPED;
34 process_id_ = -1; 37 process_id_ = -1;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 72 }
70 73
71 EmbeddedWorkerInstance::EmbeddedWorkerInstance( 74 EmbeddedWorkerInstance::EmbeddedWorkerInstance(
72 EmbeddedWorkerRegistry* registry, 75 EmbeddedWorkerRegistry* registry,
73 int embedded_worker_id) 76 int embedded_worker_id)
74 : registry_(registry), 77 : registry_(registry),
75 embedded_worker_id_(embedded_worker_id), 78 embedded_worker_id_(embedded_worker_id),
76 status_(STOPPED), 79 status_(STOPPED),
77 process_id_(-1), 80 process_id_(-1),
78 thread_id_(-1) { 81 thread_id_(-1) {
82 LOG(ERROR) << "Creating EmbeddedWorkerInstance";
79 } 83 }
80 84
81 void EmbeddedWorkerInstance::OnStarted(int thread_id) { 85 void EmbeddedWorkerInstance::OnStarted(int thread_id) {
82 // Stop is requested before OnStarted is sent back from the worker. 86 // Stop is requested before OnStarted is sent back from the worker.
83 if (status_ == STOPPING) 87 if (status_ == STOPPING)
84 return; 88 return;
85 DCHECK(status_ == STARTING); 89 DCHECK(status_ == STARTING);
86 status_ = RUNNING; 90 status_ = RUNNING;
87 thread_id_ = thread_id; 91 thread_id_ = thread_id;
88 FOR_EACH_OBSERVER(Observer, observer_list_, OnStarted()); 92 FOR_EACH_OBSERVER(Observer, observer_list_, OnStarted());
(...skipping 29 matching lines...) Expand all
118 max_ref_iter->second < iter->second) 122 max_ref_iter->second < iter->second)
119 max_ref_iter = iter; 123 max_ref_iter = iter;
120 } 124 }
121 if (max_ref_iter == process_refs_.end()) 125 if (max_ref_iter == process_refs_.end())
122 return false; 126 return false;
123 process_id_ = max_ref_iter->first; 127 process_id_ = max_ref_iter->first;
124 return true; 128 return true;
125 } 129 }
126 130
127 } // namespace content 131 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698