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

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

Issue 1779353003: service worker: Fix valgrind errors on unit_tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 | tools/valgrind/memcheck/suppressions.txt » ('j') | 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_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 <utility> 10 #include <utility>
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 : observer_list_( 94 : observer_list_(
95 new base::ObserverListThreadSafe<ServiceWorkerContextObserver>()), 95 new base::ObserverListThreadSafe<ServiceWorkerContextObserver>()),
96 process_manager_(new ServiceWorkerProcessManager(browser_context)), 96 process_manager_(new ServiceWorkerProcessManager(browser_context)),
97 is_incognito_(false), 97 is_incognito_(false),
98 storage_partition_(nullptr), 98 storage_partition_(nullptr),
99 resource_context_(nullptr) { 99 resource_context_(nullptr) {
100 DCHECK_CURRENTLY_ON(BrowserThread::UI); 100 DCHECK_CURRENTLY_ON(BrowserThread::UI);
101 } 101 }
102 102
103 ServiceWorkerContextWrapper::~ServiceWorkerContextWrapper() { 103 ServiceWorkerContextWrapper::~ServiceWorkerContextWrapper() {
104 DCHECK(!resource_context_);
105 DCHECK(!request_context_getter_);
104 } 106 }
105 107
106 void ServiceWorkerContextWrapper::Init( 108 void ServiceWorkerContextWrapper::Init(
107 const base::FilePath& user_data_directory, 109 const base::FilePath& user_data_directory,
108 storage::QuotaManagerProxy* quota_manager_proxy, 110 storage::QuotaManagerProxy* quota_manager_proxy,
109 storage::SpecialStoragePolicy* special_storage_policy) { 111 storage::SpecialStoragePolicy* special_storage_policy) {
110 DCHECK_CURRENTLY_ON(BrowserThread::UI); 112 DCHECK_CURRENTLY_ON(BrowserThread::UI);
111 113
112 is_incognito_ = user_data_directory.empty(); 114 is_incognito_ = user_data_directory.empty();
113 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); 115 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool();
(...skipping 22 matching lines...) Expand all
136 DCHECK_CURRENTLY_ON(BrowserThread::IO); 138 DCHECK_CURRENTLY_ON(BrowserThread::IO);
137 resource_context_ = resource_context; 139 resource_context_ = resource_context;
138 request_context_getter_ = request_context_getter; 140 request_context_getter_ = request_context_getter;
139 // Can be null in tests. 141 // Can be null in tests.
140 if (request_context_getter_) 142 if (request_context_getter_)
141 request_context_getter_->AddObserver(this); 143 request_context_getter_->AddObserver(this);
142 } 144 }
143 145
144 void ServiceWorkerContextWrapper::OnContextShuttingDown() { 146 void ServiceWorkerContextWrapper::OnContextShuttingDown() {
145 DCHECK_CURRENTLY_ON(BrowserThread::IO); 147 DCHECK_CURRENTLY_ON(BrowserThread::IO);
146 request_context_getter_->RemoveObserver(this);
147 148
148 // OnContextShuttingDown is called when the ProfileIOData (ResourceContext) is 149 // OnContextShuttingDown is called when the ProfileIOData (ResourceContext) is
149 // shutting down, so call ShutdownOnIO() to clear resource_context_. 150 // shutting down, so call ShutdownOnIO() to clear resource_context_.
150 // This doesn't seem to be called when using content_shell, so we still must 151 // This doesn't seem to be called when using content_shell, so we still must
151 // also call ShutdownOnIO() in Shutdown(), which is called when the storage 152 // also call ShutdownOnIO() in Shutdown(), which is called when the storage
152 // partition is destroyed. 153 // partition is destroyed.
153 ShutdownOnIO(); 154 ShutdownOnIO();
154 } 155 }
155 156
156 void ServiceWorkerContextWrapper::DeleteAndStartOver() { 157 void ServiceWorkerContextWrapper::DeleteAndStartOver() {
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 if (quota_manager_proxy) { 692 if (quota_manager_proxy) {
692 quota_manager_proxy->RegisterClient(new ServiceWorkerQuotaClient(this)); 693 quota_manager_proxy->RegisterClient(new ServiceWorkerQuotaClient(this));
693 } 694 }
694 context_core_.reset(new ServiceWorkerContextCore( 695 context_core_.reset(new ServiceWorkerContextCore(
695 user_data_directory, std::move(database_task_manager), disk_cache_thread, 696 user_data_directory, std::move(database_task_manager), disk_cache_thread,
696 quota_manager_proxy, special_storage_policy, observer_list_.get(), this)); 697 quota_manager_proxy, special_storage_policy, observer_list_.get(), this));
697 } 698 }
698 699
699 void ServiceWorkerContextWrapper::ShutdownOnIO() { 700 void ServiceWorkerContextWrapper::ShutdownOnIO() {
700 DCHECK_CURRENTLY_ON(BrowserThread::IO); 701 DCHECK_CURRENTLY_ON(BrowserThread::IO);
702 // Can be null in tests.
703 if (request_context_getter_)
704 request_context_getter_->RemoveObserver(this);
705 request_context_getter_ = nullptr;
701 resource_context_ = nullptr; 706 resource_context_ = nullptr;
702 context_core_.reset(); 707 context_core_.reset();
703 } 708 }
704 709
705 void ServiceWorkerContextWrapper::DidDeleteAndStartOver( 710 void ServiceWorkerContextWrapper::DidDeleteAndStartOver(
706 ServiceWorkerStatusCode status) { 711 ServiceWorkerStatusCode status) {
707 DCHECK_CURRENTLY_ON(BrowserThread::IO); 712 DCHECK_CURRENTLY_ON(BrowserThread::IO);
708 if (status != SERVICE_WORKER_OK) { 713 if (status != SERVICE_WORKER_OK) {
709 context_core_.reset(); 714 context_core_.reset();
710 return; 715 return;
711 } 716 }
712 context_core_.reset(new ServiceWorkerContextCore(context_core_.get(), this)); 717 context_core_.reset(new ServiceWorkerContextCore(context_core_.get(), this));
713 DVLOG(1) << "Restarted ServiceWorkerContextCore successfully."; 718 DVLOG(1) << "Restarted ServiceWorkerContextCore successfully.";
714 719
715 observer_list_->Notify(FROM_HERE, 720 observer_list_->Notify(FROM_HERE,
716 &ServiceWorkerContextObserver::OnStorageWiped); 721 &ServiceWorkerContextObserver::OnStorageWiped);
717 } 722 }
718 723
719 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { 724 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() {
720 DCHECK_CURRENTLY_ON(BrowserThread::IO); 725 DCHECK_CURRENTLY_ON(BrowserThread::IO);
721 return context_core_.get(); 726 return context_core_.get();
722 } 727 }
723 728
724 } // namespace content 729 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | tools/valgrind/memcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698