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/service_worker_version.h" | 5 #include "content/browser/service_worker/service_worker_version.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1240 controllee_by_id_.Lookup(client_id); | 1240 controllee_by_id_.Lookup(client_id); |
1241 if (!provider_host) { | 1241 if (!provider_host) { |
1242 // The client may already have been closed, just ignore. | 1242 // The client may already have been closed, just ignore. |
1243 return; | 1243 return; |
1244 } | 1244 } |
1245 provider_host->PostMessage(message, sent_message_port_ids); | 1245 provider_host->PostMessage(message, sent_message_port_ids); |
1246 } | 1246 } |
1247 | 1247 |
1248 void ServiceWorkerVersion::OnFocusClient(int request_id, int client_id) { | 1248 void ServiceWorkerVersion::OnFocusClient(int request_id, int client_id) { |
1249 TRACE_EVENT2("ServiceWorker", | 1249 TRACE_EVENT2("ServiceWorker", |
1250 "ServiceWorkerVersion::OnFocusDocument", | 1250 "ServiceWorkerVersion::OnFocusClient", |
1251 "Request id", request_id, | 1251 "Request id", request_id, |
1252 "Client id", client_id); | 1252 "Client id", client_id); |
1253 ServiceWorkerProviderHost* provider_host = | 1253 ServiceWorkerProviderHost* provider_host = |
1254 controllee_by_id_.Lookup(client_id); | 1254 controllee_by_id_.Lookup(client_id); |
1255 if (!provider_host) { | 1255 if (!provider_host) { |
1256 // The client may already have been closed, just ignore. | 1256 // The client may already have been closed, just ignore. |
1257 return; | 1257 return; |
1258 } | 1258 } |
1259 | 1259 |
1260 provider_host->Focus( | 1260 provider_host->Focus( |
1261 base::Bind(&ServiceWorkerVersion::OnFocusClientFinished, | 1261 base::Bind(&ServiceWorkerVersion::OnFocusClientFinished, |
1262 weak_factory_.GetWeakPtr(), | 1262 weak_factory_.GetWeakPtr(), |
1263 request_id)); | 1263 request_id, |
| 1264 client_id)); |
1264 } | 1265 } |
1265 | 1266 |
1266 void ServiceWorkerVersion::OnFocusClientFinished(int request_id, bool result) { | 1267 void ServiceWorkerVersion::OnFocusClientFinished( |
| 1268 int request_id, |
| 1269 int cliend_id, |
| 1270 const ServiceWorkerClientInfo& client) { |
1267 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1271 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
1268 | 1272 |
1269 if (running_status() != RUNNING) | 1273 if (running_status() != RUNNING) |
1270 return; | 1274 return; |
1271 | 1275 |
| 1276 ServiceWorkerClientInfo client_info(client); |
| 1277 client_info.client_id = cliend_id; |
| 1278 |
1272 embedded_worker_->SendMessage(ServiceWorkerMsg_FocusClientResponse( | 1279 embedded_worker_->SendMessage(ServiceWorkerMsg_FocusClientResponse( |
1273 request_id, result)); | 1280 request_id, client_info)); |
1274 } | 1281 } |
1275 | 1282 |
1276 void ServiceWorkerVersion::OnSkipWaiting(int request_id) { | 1283 void ServiceWorkerVersion::OnSkipWaiting(int request_id) { |
1277 skip_waiting_ = true; | 1284 skip_waiting_ = true; |
1278 if (status_ != INSTALLED) | 1285 if (status_ != INSTALLED) |
1279 return DidSkipWaiting(request_id); | 1286 return DidSkipWaiting(request_id); |
1280 | 1287 |
1281 if (!context_) | 1288 if (!context_) |
1282 return; | 1289 return; |
1283 ServiceWorkerRegistration* registration = | 1290 ServiceWorkerRegistration* registration = |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1410 int request_id) { | 1417 int request_id) { |
1411 callbacks->Remove(request_id); | 1418 callbacks->Remove(request_id); |
1412 if (is_doomed_) { | 1419 if (is_doomed_) { |
1413 // The stop should be already scheduled, but try to stop immediately, in | 1420 // The stop should be already scheduled, but try to stop immediately, in |
1414 // order to release worker resources soon. | 1421 // order to release worker resources soon. |
1415 StopWorkerIfIdle(); | 1422 StopWorkerIfIdle(); |
1416 } | 1423 } |
1417 } | 1424 } |
1418 | 1425 |
1419 } // namespace content | 1426 } // namespace content |
OLD | NEW |