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

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

Issue 2833723004: Check the existence of SWContext in DidUpdateNavigationPreloadEnabled/Hexistence (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/service_worker_dispatcher_host.h" 5 #include "content/browser/service_worker/service_worker_dispatcher_host.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/debug/crash_logging.h" 9 #include "base/debug/crash_logging.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after
1545 int registration_id, 1545 int registration_id,
1546 bool enable, 1546 bool enable,
1547 ServiceWorkerStatusCode status) { 1547 ServiceWorkerStatusCode status) {
1548 if (status != SERVICE_WORKER_OK) { 1548 if (status != SERVICE_WORKER_OK) {
1549 Send(new ServiceWorkerMsg_EnableNavigationPreloadError( 1549 Send(new ServiceWorkerMsg_EnableNavigationPreloadError(
1550 thread_id, request_id, WebServiceWorkerError::kErrorTypeUnknown, 1550 thread_id, request_id, WebServiceWorkerError::kErrorTypeUnknown,
1551 std::string(kEnableNavigationPreloadErrorPrefix) + 1551 std::string(kEnableNavigationPreloadErrorPrefix) +
1552 std::string(kDatabaseErrorMessage))); 1552 std::string(kDatabaseErrorMessage)));
1553 return; 1553 return;
1554 } 1554 }
1555 if (!GetContext())
1556 return;
1555 ServiceWorkerRegistration* registration = 1557 ServiceWorkerRegistration* registration =
1556 GetContext()->GetLiveRegistration(registration_id); 1558 GetContext()->GetLiveRegistration(registration_id);
1557 if (registration) 1559 if (registration)
1558 registration->EnableNavigationPreload(enable); 1560 registration->EnableNavigationPreload(enable);
1559 Send(new ServiceWorkerMsg_DidEnableNavigationPreload(thread_id, request_id)); 1561 Send(new ServiceWorkerMsg_DidEnableNavigationPreload(thread_id, request_id));
1560 } 1562 }
1561 1563
1562 void ServiceWorkerDispatcherHost::DidUpdateNavigationPreloadHeader( 1564 void ServiceWorkerDispatcherHost::DidUpdateNavigationPreloadHeader(
1563 int thread_id, 1565 int thread_id,
1564 int request_id, 1566 int request_id,
1565 int registration_id, 1567 int registration_id,
1566 const std::string& value, 1568 const std::string& value,
1567 ServiceWorkerStatusCode status) { 1569 ServiceWorkerStatusCode status) {
1568 if (status != SERVICE_WORKER_OK) { 1570 if (status != SERVICE_WORKER_OK) {
1569 Send(new ServiceWorkerMsg_SetNavigationPreloadHeaderError( 1571 Send(new ServiceWorkerMsg_SetNavigationPreloadHeaderError(
1570 thread_id, request_id, WebServiceWorkerError::kErrorTypeUnknown, 1572 thread_id, request_id, WebServiceWorkerError::kErrorTypeUnknown,
1571 std::string(kSetNavigationPreloadHeaderErrorPrefix) + 1573 std::string(kSetNavigationPreloadHeaderErrorPrefix) +
1572 std::string(kDatabaseErrorMessage))); 1574 std::string(kDatabaseErrorMessage)));
1573 return; 1575 return;
1574 } 1576 }
1577 if (!GetContext())
1578 return;
1575 ServiceWorkerRegistration* registration = 1579 ServiceWorkerRegistration* registration =
1576 GetContext()->GetLiveRegistration(registration_id); 1580 GetContext()->GetLiveRegistration(registration_id);
1577 if (registration) 1581 if (registration)
1578 registration->SetNavigationPreloadHeader(value); 1582 registration->SetNavigationPreloadHeader(value);
1579 Send(new ServiceWorkerMsg_DidSetNavigationPreloadHeader(thread_id, 1583 Send(new ServiceWorkerMsg_DidSetNavigationPreloadHeader(thread_id,
1580 request_id)); 1584 request_id));
1581 } 1585 }
1582 1586
1583 void ServiceWorkerDispatcherHost::OnTerminateWorker(int handle_id) { 1587 void ServiceWorkerDispatcherHost::OnTerminateWorker(int handle_id) {
1584 ServiceWorkerHandle* handle = handles_.Lookup(handle_id); 1588 ServiceWorkerHandle* handle = handles_.Lookup(handle_id);
1585 if (!handle) { 1589 if (!handle) {
1586 bad_message::ReceivedBadMessage(this, 1590 bad_message::ReceivedBadMessage(this,
1587 bad_message::SWDH_TERMINATE_BAD_HANDLE); 1591 bad_message::SWDH_TERMINATE_BAD_HANDLE);
1588 return; 1592 return;
1589 } 1593 }
1590 handle->version()->StopWorker( 1594 handle->version()->StopWorker(
1591 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); 1595 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
1592 } 1596 }
1593 1597
1594 } // namespace content 1598 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698