OLD | NEW |
---|---|
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 LOG(ERROR) << "Starting EmbeddedWorkerInstance"; | |
kinuko
2014/01/29 09:56:20
You could add these logs with DVLOG(1) so that we
alecflett
2014/01/30 01:51:13
I don't think these are super useful, all of the L
| |
21 DCHECK(status_ == STOPPED); | 22 DCHECK(status_ == STOPPED); |
22 if (!ChooseProcess()) | 23 if (!ChooseProcess()) { |
24 LOG(ERROR) << "Couldnl't find process to run worker.."; | |
kinuko
2014/01/29 09:56:20
I'm changing StartWorker() to return PROCESS_NOT_F
alecflett
2014/01/30 01:51:13
Yep, will do!
| |
23 return false; | 25 return false; |
26 } | |
24 status_ = STARTING; | 27 status_ = STARTING; |
25 bool success = registry_->StartWorker( | 28 bool success = registry_->StartWorker( |
26 process_id_, | 29 process_id_, |
27 embedded_worker_id_, | 30 embedded_worker_id_, |
28 service_worker_version_id, | 31 service_worker_version_id, |
29 script_url); | 32 script_url); |
30 if (!success) { | 33 if (!success) { |
31 status_ = STOPPED; | 34 status_ = STOPPED; |
32 process_id_ = -1; | 35 process_id_ = -1; |
33 } | 36 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 } | 70 } |
68 | 71 |
69 EmbeddedWorkerInstance::EmbeddedWorkerInstance( | 72 EmbeddedWorkerInstance::EmbeddedWorkerInstance( |
70 EmbeddedWorkerRegistry* registry, | 73 EmbeddedWorkerRegistry* registry, |
71 int embedded_worker_id) | 74 int embedded_worker_id) |
72 : registry_(registry), | 75 : registry_(registry), |
73 embedded_worker_id_(embedded_worker_id), | 76 embedded_worker_id_(embedded_worker_id), |
74 status_(STOPPED), | 77 status_(STOPPED), |
75 process_id_(-1), | 78 process_id_(-1), |
76 thread_id_(-1) { | 79 thread_id_(-1) { |
80 LOG(ERROR) << "Creating EmbeddedWorkerInstance"; | |
77 } | 81 } |
78 | 82 |
79 void EmbeddedWorkerInstance::OnStarted(int thread_id) { | 83 void EmbeddedWorkerInstance::OnStarted(int thread_id) { |
80 // Stop is requested before OnStarted is sent back from the worker. | 84 // Stop is requested before OnStarted is sent back from the worker. |
81 if (status_ == STOPPING) | 85 if (status_ == STOPPING) |
82 return; | 86 return; |
83 DCHECK(status_ == STARTING); | 87 DCHECK(status_ == STARTING); |
84 status_ = RUNNING; | 88 status_ = RUNNING; |
85 thread_id_ = thread_id; | 89 thread_id_ = thread_id; |
86 FOR_EACH_OBSERVER(Observer, observer_list_, OnStarted()); | 90 FOR_EACH_OBSERVER(Observer, observer_list_, OnStarted()); |
(...skipping 29 matching lines...) Expand all Loading... | |
116 max_ref_iter->second < iter->second) | 120 max_ref_iter->second < iter->second) |
117 max_ref_iter = iter; | 121 max_ref_iter = iter; |
118 } | 122 } |
119 if (max_ref_iter == process_refs_.end()) | 123 if (max_ref_iter == process_refs_.end()) |
120 return false; | 124 return false; |
121 process_id_ = max_ref_iter->first; | 125 process_id_ = max_ref_iter->first; |
122 return true; | 126 return true; |
123 } | 127 } |
124 | 128 |
125 } // namespace content | 129 } // namespace content |
OLD | NEW |