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

Side by Side Diff: chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.cc

Issue 2781083002: Fix the multi-threaded access to WeakPtr<BrowsingDataRemoverImpl> (Closed)
Patch Set: Ordering 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" 5 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 #if defined(OS_ANDROID) 304 #if defined(OS_ANDROID)
305 webapp_registry_(new WebappRegistry()), 305 webapp_registry_(new WebappRegistry()),
306 #endif 306 #endif
307 weak_ptr_factory_(this) {} 307 weak_ptr_factory_(this) {}
308 308
309 ChromeBrowsingDataRemoverDelegate::~ChromeBrowsingDataRemoverDelegate() { 309 ChromeBrowsingDataRemoverDelegate::~ChromeBrowsingDataRemoverDelegate() {
310 history_task_tracker_.TryCancelAll(); 310 history_task_tracker_.TryCancelAll();
311 template_url_sub_.reset(); 311 template_url_sub_.reset();
312 } 312 }
313 313
314 bool ChromeBrowsingDataRemoverDelegate::DoesOriginMatchEmbedderMask( 314 BrowsingDataRemoverDelegate::EmbedderOriginTypeMatcher
315 int origin_type_mask, 315 ChromeBrowsingDataRemoverDelegate::GetOriginTypeMatcher() const {
316 const GURL& origin, 316 return base::Bind(DoesOriginMatchEmbedderMask);
317 storage::SpecialStoragePolicy* policy) const {
318 DCHECK_EQ(0, origin_type_mask & (ORIGIN_TYPE_EMBEDDER_BEGIN - 1))
319 << "|origin_type_mask| can only contain origin types defined in "
320 << "the embedder.";
321
322 #if BUILDFLAG(ENABLE_EXTENSIONS)
323 // Packaged apps and extensions match iff EXTENSION.
324 if ((origin.GetOrigin().scheme() == extensions::kExtensionScheme) &&
325 (origin_type_mask & ORIGIN_TYPE_EXTENSION)) {
326 return true;
327 }
328 origin_type_mask &= ~ORIGIN_TYPE_EXTENSION;
329 #endif
330
331 DCHECK(!origin_type_mask)
332 << "DoesOriginMatchEmbedderMask must handle all origin types.";
333
334 return false;
335 } 317 }
336 318
337 void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData( 319 void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData(
338 const base::Time& delete_begin, 320 const base::Time& delete_begin,
339 const base::Time& delete_end, 321 const base::Time& delete_end,
340 int remove_mask, 322 int remove_mask,
341 const BrowsingDataFilterBuilder& filter_builder, 323 const BrowsingDataFilterBuilder& filter_builder,
342 int origin_type_mask, 324 int origin_type_mask,
343 const base::Closure& callback) { 325 const base::Closure& callback) {
344 DCHECK(((remove_mask & ~FILTERABLE_DATA_TYPES) == 0) || 326 DCHECK(((remove_mask & ~FILTERABLE_DATA_TYPES) == 0) ||
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 #endif 975 #endif
994 976
995 ////////////////////////////////////////////////////////////////////////////// 977 //////////////////////////////////////////////////////////////////////////////
996 // Remove external protocol data. 978 // Remove external protocol data.
997 if (remove_mask & DATA_TYPE_EXTERNAL_PROTOCOL_DATA) 979 if (remove_mask & DATA_TYPE_EXTERNAL_PROTOCOL_DATA)
998 ExternalProtocolHandler::ClearData(profile_); 980 ExternalProtocolHandler::ClearData(profile_);
999 981
1000 synchronous_clear_operations_.GetCompletionCallback().Run(); 982 synchronous_clear_operations_.GetCompletionCallback().Run();
1001 } 983 }
1002 984
985 // static
986 bool ChromeBrowsingDataRemoverDelegate::DoesOriginMatchEmbedderMask(
987 int origin_type_mask,
988 const GURL& origin,
989 storage::SpecialStoragePolicy* policy) {
990 DCHECK_EQ(0, origin_type_mask & (ORIGIN_TYPE_EMBEDDER_BEGIN - 1))
991 << "|origin_type_mask| can only contain origin types defined in "
992 << "the embedder.";
993
994 #if BUILDFLAG(ENABLE_EXTENSIONS)
995 // Packaged apps and extensions match iff EXTENSION.
996 if ((origin.GetOrigin().scheme() == extensions::kExtensionScheme) &&
997 (origin_type_mask & ORIGIN_TYPE_EXTENSION)) {
998 return true;
999 }
1000 origin_type_mask &= ~ORIGIN_TYPE_EXTENSION;
1001 #endif
1002
1003 DCHECK(!origin_type_mask)
1004 << "DoesOriginMatchEmbedderMask must handle all origin types.";
1005
1006 return false;
1007 }
1008
1003 void ChromeBrowsingDataRemoverDelegate::NotifyIfDone() { 1009 void ChromeBrowsingDataRemoverDelegate::NotifyIfDone() {
1004 if (!AllDone()) 1010 if (!AllDone())
1005 return; 1011 return;
1006 1012
1007 DCHECK(!callback_.is_null()); 1013 DCHECK(!callback_.is_null());
1008 callback_.Run(); 1014 callback_.Run();
1009 } 1015 }
1010 1016
1011 bool ChromeBrowsingDataRemoverDelegate::AllDone() { 1017 bool ChromeBrowsingDataRemoverDelegate::AllDone() {
1012 return !clear_cookies_count_ && !synchronous_clear_operations_.is_pending() && 1018 return !clear_cookies_count_ && !synchronous_clear_operations_.is_pending() &&
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 } 1128 }
1123 1129
1124 void ChromeBrowsingDataRemoverDelegate:: 1130 void ChromeBrowsingDataRemoverDelegate::
1125 OnDeauthorizeFlashContentLicensesCompleted( 1131 OnDeauthorizeFlashContentLicensesCompleted(
1126 uint32_t request_id, 1132 uint32_t request_id,
1127 bool /* success */) { 1133 bool /* success */) {
1128 DCHECK_EQ(request_id, deauthorize_flash_content_licenses_request_id_); 1134 DCHECK_EQ(request_id, deauthorize_flash_content_licenses_request_id_);
1129 clear_flash_content_licenses_.GetCompletionCallback().Run(); 1135 clear_flash_content_licenses_.GetCompletionCallback().Run();
1130 } 1136 }
1131 #endif 1137 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698