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

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

Issue 1429753002: ServiceWorker: Remove dead code from ServiceWorkerContextWrapper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix "include" dependency Created 5 years, 1 month 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
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_context_wrapper.h" 5 #include "content/browser/service_worker/service_worker_context_wrapper.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/barrier_closure.h" 12 #include "base/barrier_closure.h"
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/lazy_instance.h" 15 #include "base/lazy_instance.h"
16 #include "base/location.h" 16 #include "base/location.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/profiler/scoped_tracker.h" 18 #include "base/profiler/scoped_tracker.h"
19 #include "base/single_thread_task_runner.h" 19 #include "base/single_thread_task_runner.h"
20 #include "base/thread_task_runner_handle.h" 20 #include "base/thread_task_runner_handle.h"
21 #include "base/threading/sequenced_worker_pool.h" 21 #include "base/threading/sequenced_worker_pool.h"
22 #include "content/browser/service_worker/service_worker_context_core.h" 22 #include "content/browser/service_worker/service_worker_context_core.h"
23 #include "content/browser/service_worker/service_worker_context_observer.h" 23 #include "content/browser/service_worker/service_worker_context_observer.h"
24 #include "content/browser/service_worker/service_worker_process_manager.h" 24 #include "content/browser/service_worker/service_worker_process_manager.h"
25 #include "content/browser/service_worker/service_worker_quota_client.h" 25 #include "content/browser/service_worker/service_worker_quota_client.h"
26 #include "content/browser/service_worker/service_worker_request_handler.h"
27 #include "content/browser/service_worker/service_worker_version.h" 26 #include "content/browser/service_worker/service_worker_version.h"
28 #include "content/browser/storage_partition_impl.h" 27 #include "content/browser/storage_partition_impl.h"
29 #include "content/common/service_worker/service_worker_utils.h" 28 #include "content/common/service_worker/service_worker_utils.h"
30 #include "content/public/browser/browser_context.h" 29 #include "content/public/browser/browser_context.h"
31 #include "content/public/browser/browser_thread.h" 30 #include "content/public/browser/browser_thread.h"
32 #include "content/public/browser/service_worker_context.h"
33 #include "net/base/net_errors.h"
34 #include "net/base/net_util.h" 31 #include "net/base/net_util.h"
35 #include "storage/browser/quota/quota_manager_proxy.h" 32 #include "storage/browser/quota/quota_manager_proxy.h"
36 #include "storage/browser/quota/special_storage_policy.h" 33 #include "storage/browser/quota/special_storage_policy.h"
37 34
38 namespace content { 35 namespace content {
39 36
40 namespace { 37 namespace {
41 38
42 typedef std::set<std::string> HeaderNameSet; 39 typedef std::set<std::string> HeaderNameSet;
43 base::LazyInstance<HeaderNameSet> g_excluded_header_name_set = 40 base::LazyInstance<HeaderNameSet> g_excluded_header_name_set =
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 header_names.end()); 81 header_names.end());
85 } 82 }
86 83
87 bool ServiceWorkerContext::IsExcludedHeaderNameForFetchEvent( 84 bool ServiceWorkerContext::IsExcludedHeaderNameForFetchEvent(
88 const std::string& header_name) { 85 const std::string& header_name) {
89 DCHECK_CURRENTLY_ON(BrowserThread::IO); 86 DCHECK_CURRENTLY_ON(BrowserThread::IO);
90 return g_excluded_header_name_set.Get().find(header_name) != 87 return g_excluded_header_name_set.Get().find(header_name) !=
91 g_excluded_header_name_set.Get().end(); 88 g_excluded_header_name_set.Get().end();
92 } 89 }
93 90
94 ServiceWorkerContext* ServiceWorkerContext::GetServiceWorkerContext(
95 net::URLRequest* request) {
96 DCHECK_CURRENTLY_ON(BrowserThread::IO);
97 ServiceWorkerRequestHandler* handler =
98 ServiceWorkerRequestHandler::GetHandler(request);
99 if (!handler || !handler->context())
100 return nullptr;
101 return handler->context()->wrapper_;
102 }
103
104 ServiceWorkerContextWrapper::ServiceWorkerContextWrapper( 91 ServiceWorkerContextWrapper::ServiceWorkerContextWrapper(
105 BrowserContext* browser_context) 92 BrowserContext* browser_context)
106 : observer_list_( 93 : observer_list_(
107 new base::ObserverListThreadSafe<ServiceWorkerContextObserver>()), 94 new base::ObserverListThreadSafe<ServiceWorkerContextObserver>()),
108 process_manager_(new ServiceWorkerProcessManager(browser_context)), 95 process_manager_(new ServiceWorkerProcessManager(browser_context)),
109 is_incognito_(false), 96 is_incognito_(false),
110 storage_partition_(nullptr), 97 storage_partition_(nullptr),
111 resource_context_(nullptr) { 98 resource_context_(nullptr) {
112 DCHECK_CURRENTLY_ON(BrowserThread::UI); 99 DCHECK_CURRENTLY_ON(BrowserThread::UI);
113 } 100 }
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 base::Bind(&ServiceWorkerContextWrapper::SetForceUpdateOnPageLoad, this, 287 base::Bind(&ServiceWorkerContextWrapper::SetForceUpdateOnPageLoad, this,
301 registration_id, force_update_on_page_load)); 288 registration_id, force_update_on_page_load));
302 return; 289 return;
303 } 290 }
304 if (!context_core_) 291 if (!context_core_)
305 return; 292 return;
306 context_core_->SetForceUpdateOnPageLoad(registration_id, 293 context_core_->SetForceUpdateOnPageLoad(registration_id,
307 force_update_on_page_load); 294 force_update_on_page_load);
308 } 295 }
309 296
310 static void DidFindRegistrationForDocument(
311 const net::CompletionCallback& callback,
312 ServiceWorkerStatusCode status,
313 const scoped_refptr<ServiceWorkerRegistration>& registration) {
314 int rv = registration ? net::OK : net::ERR_CACHE_MISS;
315 // Use RunSoon here because FindRegistrationForDocument can complete
316 // immediately but CanHandleMainResourceOffline must be async.
317 RunSoon(base::Bind(callback, rv));
318 }
319
320 void ServiceWorkerContextWrapper::CanHandleMainResourceOffline(
321 const GURL& url,
322 const GURL& first_party,
323 const net::CompletionCallback& callback) {
324 DCHECK_CURRENTLY_ON(BrowserThread::IO);
325 context()->storage()->FindRegistrationForDocument(
326 net::SimplifyUrlForRequest(url),
327 base::Bind(&DidFindRegistrationForDocument, callback));
328 }
329
330 void ServiceWorkerContextWrapper::GetAllOriginsInfo( 297 void ServiceWorkerContextWrapper::GetAllOriginsInfo(
331 const GetUsageInfoCallback& callback) { 298 const GetUsageInfoCallback& callback) {
332 DCHECK_CURRENTLY_ON(BrowserThread::IO); 299 DCHECK_CURRENTLY_ON(BrowserThread::IO);
333 if (!context_core_) { 300 if (!context_core_) {
334 BrowserThread::PostTask( 301 BrowserThread::PostTask(
335 BrowserThread::IO, 302 BrowserThread::IO,
336 FROM_HERE, 303 FROM_HERE,
337 base::Bind(callback, std::vector<ServiceWorkerUsageInfo>())); 304 base::Bind(callback, std::vector<ServiceWorkerUsageInfo>()));
338 return; 305 return;
339 } 306 }
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 observer_list_->Notify(FROM_HERE, 705 observer_list_->Notify(FROM_HERE,
739 &ServiceWorkerContextObserver::OnStorageWiped); 706 &ServiceWorkerContextObserver::OnStorageWiped);
740 } 707 }
741 708
742 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { 709 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() {
743 DCHECK_CURRENTLY_ON(BrowserThread::IO); 710 DCHECK_CURRENTLY_ON(BrowserThread::IO);
744 return context_core_.get(); 711 return context_core_.get();
745 } 712 }
746 713
747 } // namespace content 714 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698