1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "content/browser/storage_partition_impl.h" 6 7 #include "base/sequenced_task_runner.h" 8 #include "base/strings/utf_string_conversions.h" 9 #include "content/browser/browser_main_loop.h" 10 #include "content/browser/fileapi/browser_file_system_helper.h" 11 #include "content/browser/gpu/shader_disk_cache.h" 12 #include "content/common/dom_storage/dom_storage_types.h" 13 #include "content/public/browser/browser_context.h" 14 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/dom_storage_context.h" 16 #include "content/public/browser/indexed_db_context.h" 17 #include "content/public/browser/local_storage_usage_info.h" 18 #include "content/public/browser/session_storage_usage_info.h" 19 #include "net/base/completion_callback.h" 20 #include "net/base/net_errors.h" 21 #include "net/cookies/cookie_monster.h" 22 #include "net/url_request/url_request_context.h" 23 #include "net/url_request/url_request_context_getter.h" 24 #include "webkit/browser/database/database_tracker.h" 25 #include "webkit/browser/quota/quota_manager.h" 26 27 namespace content { 28 29 namespace { 30 31 int GenerateQuotaClientMask(uint32 remove_mask) { 32 int quota_client_mask = 0; 33 34 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS) 35 quota_client_mask |= quota::QuotaClient::kFileSystem; 36 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_WEBSQL) 37 quota_client_mask |= quota::QuotaClient::kDatabase; 38 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_APPCACHE) 39 quota_client_mask |= quota::QuotaClient::kAppcache; 40 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_INDEXEDDB) 41 quota_client_mask |= quota::QuotaClient::kIndexedDatabase; 42 43 return quota_client_mask; 44 } 45 46 void OnClearedCookies(const base::Closure& callback, int num_deleted) { 47 // The final callback needs to happen from UI thread. 48 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 49 BrowserThread::PostTask( 50 BrowserThread::UI, FROM_HERE, 51 base::Bind(&OnClearedCookies, callback, num_deleted)); 52 return; 53 } 54 55 callback.Run(); 56 } 57 58 void ClearCookiesOnIOThread( 59 const scoped_refptr<net::URLRequestContextGetter>& rq_context, 60 const base::Time begin, 61 const base::Time end, 62 const GURL& remove_origin, 63 const base::Closure& callback) { 64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 65 net::CookieStore* cookie_store = rq_context-> 66 GetURLRequestContext()->cookie_store(); 67 if (remove_origin.is_empty()) { 68 cookie_store->GetCookieMonster()->DeleteAllCreatedBetweenAsync( 69 begin, 70 end, 71 base::Bind(&OnClearedCookies, callback)); 72 } else { 73 cookie_store->GetCookieMonster()->DeleteAllCreatedBetweenForHostAsync( 74 begin, 75 end, 76 remove_origin, base::Bind(&OnClearedCookies, callback)); 77 } 78 } 79 80 void OnQuotaManagedOriginDeleted(const GURL& origin, 81 quota::StorageType type, 82 size_t* origins_to_delete_count, 83 const base::Closure& callback, 84 quota::QuotaStatusCode status) { 85 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 86 DCHECK_GT(*origins_to_delete_count, 0u); 87 if (status != quota::kQuotaStatusOk) { 88 DLOG(ERROR) << "Couldn't remove data of type " << type << " for origin " 89 << origin << ". Status: " << status; 90 } 91 92 (*origins_to_delete_count)--; 93 if (*origins_to_delete_count == 0) { 94 delete origins_to_delete_count; 95 callback.Run(); 96 } 97 } 98 99 void ClearQuotaManagedOriginsOnIOThread(quota::QuotaManager* quota_manager, 100 uint32 remove_mask, 101 const base::Closure& callback, 102 const std::set<GURL>& origins, 103 quota::StorageType quota_storage_type) { 104 // The QuotaManager manages all storage other than cookies, LocalStorage, 105 // and SessionStorage. This loop wipes out most HTML5 storage for the given 106 // origins. 107 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 108 109 if (!origins.size()) { 110 // No origins to clear. 111 callback.Run(); 112 return; 113 } 114 115 std::set<GURL>::const_iterator origin; 116 size_t* origins_to_delete_count = new size_t(origins.size()); 117 for (std::set<GURL>::const_iterator origin = origins.begin(); 118 origin != origins.end(); ++origin) { 119 quota_manager->DeleteOriginData( 120 *origin, quota_storage_type, 121 GenerateQuotaClientMask(remove_mask), 122 base::Bind(&OnQuotaManagedOriginDeleted, 123 origin->GetOrigin(), quota_storage_type, 124 origins_to_delete_count, callback)); 125 } 126 } 127 128 void ClearedShaderCache(const base::Closure& callback) { 129 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 130 BrowserThread::PostTask( 131 BrowserThread::UI, FROM_HERE, 132 base::Bind(&ClearedShaderCache, callback)); 133 return; 134 } 135 callback.Run(); 136 } 137 138 void ClearShaderCacheOnIOThread(const base::FilePath& path, 139 const base::Time begin, 140 const base::Time end, 141 const base::Closure& callback) { 142 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 143 ShaderCacheFactory::GetInstance()->ClearByPath( 144 path, begin, end, base::Bind(&ClearedShaderCache, callback)); 145 } 146 147 void OnLocalStorageUsageInfo( 148 const scoped_refptr<DOMStorageContextWrapper>& dom_storage_context, 149 const base::Time delete_begin, 150 const base::Time delete_end, 151 const base::Closure& callback, 152 const std::vector<LocalStorageUsageInfo>& infos) { 153 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 154 155 for (size_t i = 0; i < infos.size(); ++i) { 156 if (infos[i].last_modified >= delete_begin && 157 infos[i].last_modified <= delete_end) { 158 dom_storage_context->DeleteLocalStorage(infos[i].origin); 159 } 160 } 161 callback.Run(); 162 } 163 164 void OnSessionStorageUsageInfo( 165 const scoped_refptr<DOMStorageContextWrapper>& dom_storage_context, 166 const base::Closure& callback, 167 const std::vector<SessionStorageUsageInfo>& infos) { 168 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 169 170 for (size_t i = 0; i < infos.size(); ++i) 171 dom_storage_context->DeleteSessionStorage(infos[i]); 172 173 callback.Run(); 174 } 175 176 void ClearLocalStorageOnUIThread( 177 const scoped_refptr<DOMStorageContextWrapper>& dom_storage_context, 178 const GURL& remove_origin, 179 const base::Time begin, 180 const base::Time end, 181 const base::Closure& callback) { 182 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 183 184 if (!remove_origin.is_empty()) { 185 dom_storage_context->DeleteLocalStorage(remove_origin); 186 callback.Run(); 187 return; 188 } 189 190 dom_storage_context->GetLocalStorageUsage( 191 base::Bind(&OnLocalStorageUsageInfo, 192 dom_storage_context, begin, end, callback)); 193 } 194 195 void ClearSessionStorageOnUIThread( 196 const scoped_refptr<DOMStorageContextWrapper>& dom_storage_context, 197 const base::Closure& callback) { 198 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 199 200 dom_storage_context->GetSessionStorageUsage( 201 base::Bind(&OnSessionStorageUsageInfo, dom_storage_context, callback)); 202 } 203 204 } // namespace 205 206 // Helper for deleting quota managed data from a partition. 207 // 208 // Most of the operations in this class are done on IO thread. 209 struct StoragePartitionImpl::QuotaManagedDataDeletionHelper { 210 QuotaManagedDataDeletionHelper(const base::Closure& callback) 211 : callback(callback), task_count(0) { 212 } 213 214 void IncrementTaskCountOnIO(); 215 void DecrementTaskCountOnIO(); 216 217 void ClearDataOnIOThread( 218 const scoped_refptr<quota::QuotaManager>& quota_manager, 219 const base::Time begin, 220 uint32 remove_mask, 221 uint32 quota_storage_remove_mask, 222 const GURL& remove_origin); 223 224 // Accessed on IO thread. 225 const base::Closure callback; 226 // Accessed on IO thread. 227 int task_count; 228 }; 229 230 // Helper for deleting all sorts of data from a partition, keeps track of 231 // deletion status. 232 // 233 // StoragePartitionImpl creates an instance of this class to keep track of 234 // data deletion progress. Deletion requires deleting multiple bits of data 235 // (e.g. cookies, local storage, session storage etc.) and hopping between UI 236 // and IO thread. An instance of this class is created in the beginning of 237 // deletion process (StoragePartitionImpl::ClearDataImpl) and the instance is 238 // forwarded and updated on each (sub) deletion's callback. The instance is 239 // finally destroyed when deletion completes (and |callback| is invoked). 240 struct StoragePartitionImpl::DataDeletionHelper { 241 DataDeletionHelper(const base::Closure& callback) 242 : callback(callback), task_count(0) { 243 } 244 245 void IncrementTaskCountOnUI(); 246 void DecrementTaskCountOnUI(); 247 248 void ClearDataOnUIThread(uint32 remove_mask, 249 uint32 quota_storage_remove_mask, 250 const GURL& remove_origin, 251 const base::FilePath& path, 252 net::URLRequestContextGetter* rq_context, 253 DOMStorageContextWrapper* dom_storage_context, 254 quota::QuotaManager* quota_manager, 255 WebRTCIdentityStore* webrtc_identity_store, 256 const base::Time begin, 257 const base::Time end); 258 259 // Accessed on UI thread. 260 const base::Closure callback; 261 // Accessed on UI thread. 262 int task_count; 263 }; 264 265 void ClearQuotaManagedDataOnIOThread( 266 const scoped_refptr<quota::QuotaManager>& quota_manager, 267 const base::Time begin, 268 uint32 remove_mask, 269 uint32 quota_storage_remove_mask, 270 const GURL& remove_origin, 271 const base::Closure& callback) { 272 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 273 274 StoragePartitionImpl::QuotaManagedDataDeletionHelper* helper = 275 new StoragePartitionImpl::QuotaManagedDataDeletionHelper(callback); 276 helper->ClearDataOnIOThread(quota_manager, begin, 277 remove_mask, quota_storage_remove_mask, remove_origin); 278 } 279 280 StoragePartitionImpl::StoragePartitionImpl( 281 const base::FilePath& partition_path, 282 quota::QuotaManager* quota_manager, 283 ChromeAppCacheService* appcache_service, 284 fileapi::FileSystemContext* filesystem_context, 285 webkit_database::DatabaseTracker* database_tracker, 286 DOMStorageContextWrapper* dom_storage_context, 287 IndexedDBContextImpl* indexed_db_context, 288 WebRTCIdentityStore* webrtc_identity_store) 289 : partition_path_(partition_path), 290 quota_manager_(quota_manager), 291 appcache_service_(appcache_service), 292 filesystem_context_(filesystem_context), 293 database_tracker_(database_tracker), 294 dom_storage_context_(dom_storage_context), 295 indexed_db_context_(indexed_db_context), 296 webrtc_identity_store_(webrtc_identity_store) {} 297 298 StoragePartitionImpl::~StoragePartitionImpl() { 299 // These message loop checks are just to avoid leaks in unittests. 300 if (GetDatabaseTracker() && 301 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { 302 BrowserThread::PostTask( 303 BrowserThread::FILE, FROM_HERE, 304 base::Bind(&webkit_database::DatabaseTracker::Shutdown, 305 GetDatabaseTracker())); 306 } 307 308 if (GetFileSystemContext()) 309 GetFileSystemContext()->Shutdown(); 310 311 if (GetDOMStorageContext()) 312 GetDOMStorageContext()->Shutdown(); 313 } 314 315 // TODO(ajwong): Break the direct dependency on |context|. We only 316 // need 3 pieces of info from it. 317 StoragePartitionImpl* StoragePartitionImpl::Create( 318 BrowserContext* context, 319 bool in_memory, 320 const base::FilePath& partition_path) { 321 // Ensure that these methods are called on the UI thread, except for 322 // unittests where a UI thread might not have been created. 323 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || 324 !BrowserThread::IsMessageLoopValid(BrowserThread::UI)); 325 326 // All of the clients have to be created and registered with the 327 // QuotaManager prior to the QuotaManger being used. We do them 328 // all together here prior to handing out a reference to anything 329 // that utilizes the QuotaManager. 330 scoped_refptr<quota::QuotaManager> quota_manager = new quota::QuotaManager( 331 in_memory, 332 partition_path, 333 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get(), 334 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB).get(), 335 context->GetSpecialStoragePolicy()); 336 337 // Each consumer is responsible for registering its QuotaClient during 338 // its construction. 339 scoped_refptr<fileapi::FileSystemContext> filesystem_context = 340 CreateFileSystemContext(context, 341 partition_path, in_memory, 342 quota_manager->proxy()); 343 344 scoped_refptr<webkit_database::DatabaseTracker> database_tracker = 345 new webkit_database::DatabaseTracker( 346 partition_path, 347 in_memory, 348 context->GetSpecialStoragePolicy(), 349 quota_manager->proxy(), 350 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE) 351 .get()); 352 353 base::FilePath path = in_memory ? base::FilePath() : partition_path; 354 scoped_refptr<DOMStorageContextWrapper> dom_storage_context = 355 new DOMStorageContextWrapper(path, context->GetSpecialStoragePolicy()); 356 357 // BrowserMainLoop may not be initialized in unit tests. Tests will 358 // need to inject their own task runner into the IndexedDBContext. 359 base::SequencedTaskRunner* idb_task_runner = 360 BrowserThread::CurrentlyOn(BrowserThread::UI) && 361 BrowserMainLoop::GetInstance() 362 ? BrowserMainLoop::GetInstance()->indexed_db_thread() 363 ->message_loop_proxy().get() 364 : NULL; 365 scoped_refptr<IndexedDBContextImpl> indexed_db_context = 366 new IndexedDBContextImpl(path, 367 context->GetSpecialStoragePolicy(), 368 quota_manager->proxy(), 369 idb_task_runner); 370 371 scoped_refptr<ChromeAppCacheService> appcache_service = 372 new ChromeAppCacheService(quota_manager->proxy()); 373 374 scoped_refptr<WebRTCIdentityStore> webrtc_identity_store( 375 new WebRTCIdentityStore(path, context->GetSpecialStoragePolicy())); 376 377 return new StoragePartitionImpl(partition_path, 378 quota_manager.get(), 379 appcache_service.get(), 380 filesystem_context.get(), 381 database_tracker.get(), 382 dom_storage_context.get(), 383 indexed_db_context.get(), 384 webrtc_identity_store.get()); 385 } 386 387 base::FilePath StoragePartitionImpl::GetPath() { 388 return partition_path_; 389 } 390 391 net::URLRequestContextGetter* StoragePartitionImpl::GetURLRequestContext() { 392 return url_request_context_.get(); 393 } 394 395 net::URLRequestContextGetter* 396 StoragePartitionImpl::GetMediaURLRequestContext() { 397 return media_url_request_context_.get(); 398 } 399 400 quota::QuotaManager* StoragePartitionImpl::GetQuotaManager() { 401 return quota_manager_.get(); 402 } 403 404 ChromeAppCacheService* StoragePartitionImpl::GetAppCacheService() { 405 return appcache_service_.get(); 406 } 407 408 fileapi::FileSystemContext* StoragePartitionImpl::GetFileSystemContext() { 409 return filesystem_context_.get(); 410 } 411 412 webkit_database::DatabaseTracker* StoragePartitionImpl::GetDatabaseTracker() { 413 return database_tracker_.get(); 414 } 415 416 DOMStorageContextWrapper* StoragePartitionImpl::GetDOMStorageContext() { 417 return dom_storage_context_.get(); 418 } 419 420 IndexedDBContextImpl* StoragePartitionImpl::GetIndexedDBContext() { 421 return indexed_db_context_.get(); 422 } 423 424 void StoragePartitionImpl::ClearDataImpl( 425 uint32 remove_mask, 426 uint32 quota_storage_remove_mask, 427 const GURL& remove_origin, 428 net::URLRequestContextGetter* rq_context, 429 const base::Time begin, 430 const base::Time end, 431 const base::Closure& callback) { 432 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 433 DataDeletionHelper* helper = new DataDeletionHelper(callback); 434 // |helper| deletes itself when done in 435 // DataDeletionHelper::DecrementTaskCountOnUI(). 436 helper->ClearDataOnUIThread( 437 remove_mask, quota_storage_remove_mask, remove_origin, 438 GetPath(), rq_context, dom_storage_context_, quota_manager_, 439 webrtc_identity_store_, begin, end); 440 } 441 442 void StoragePartitionImpl:: 443 QuotaManagedDataDeletionHelper::IncrementTaskCountOnIO() { 444 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 445 ++task_count; 446 } 447 448 void StoragePartitionImpl:: 449 QuotaManagedDataDeletionHelper::DecrementTaskCountOnIO() { 450 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 451 DCHECK_GT(task_count, 0); 452 --task_count; 453 if (task_count) 454 return; 455 456 callback.Run(); 457 delete this; 458 } 459 460 void StoragePartitionImpl::QuotaManagedDataDeletionHelper::ClearDataOnIOThread( 461 const scoped_refptr<quota::QuotaManager>& quota_manager, 462 const base::Time begin, 463 uint32 remove_mask, 464 uint32 quota_storage_remove_mask, 465 const GURL& remove_origin) { 466 std::set<GURL> origins; 467 if (!remove_origin.is_empty()) 468 origins.insert(remove_origin); 469 470 IncrementTaskCountOnIO(); 471 base::Closure decrement_callback = base::Bind( 472 &QuotaManagedDataDeletionHelper::DecrementTaskCountOnIO, 473 base::Unretained(this)); 474 475 if (quota_storage_remove_mask & QUOTA_MANAGED_STORAGE_MASK_PERSISTENT) { 476 IncrementTaskCountOnIO(); 477 if (origins.empty()) { // Remove for all origins. 478 // Ask the QuotaManager for all origins with temporary quota modified 479 // within the user-specified timeframe, and deal with the resulting set in 480 // ClearQuotaManagedOriginsOnIOThread(). 481 quota_manager->GetOriginsModifiedSince( 482 quota::kStorageTypePersistent, begin, 483 base::Bind(&ClearQuotaManagedOriginsOnIOThread, 484 quota_manager, remove_mask, decrement_callback)); 485 } else { 486 ClearQuotaManagedOriginsOnIOThread( 487 quota_manager, remove_mask, decrement_callback, 488 origins, quota::kStorageTypePersistent); 489 } 490 } 491 492 // Do the same for temporary quota. 493 if (quota_storage_remove_mask & QUOTA_MANAGED_STORAGE_MASK_TEMPORARY) { 494 IncrementTaskCountOnIO(); 495 if (origins.empty()) { // Remove for all origins. 496 quota_manager->GetOriginsModifiedSince( 497 quota::kStorageTypeTemporary, begin, 498 base::Bind(&ClearQuotaManagedOriginsOnIOThread, 499 quota_manager, remove_mask, decrement_callback)); 500 } else { 501 ClearQuotaManagedOriginsOnIOThread( 502 quota_manager, remove_mask, decrement_callback, 503 origins, quota::kStorageTypeTemporary); 504 } 505 } 506 507 // Do the same for syncable quota. 508 if (quota_storage_remove_mask & QUOTA_MANAGED_STORAGE_MASK_SYNCABLE) { 509 IncrementTaskCountOnIO(); 510 if (origins.empty()) { // Remove for all origins. 511 quota_manager->GetOriginsModifiedSince( 512 quota::kStorageTypeSyncable, begin, 513 base::Bind(&ClearQuotaManagedOriginsOnIOThread, 514 quota_manager, remove_mask, decrement_callback)); 515 } else { 516 ClearQuotaManagedOriginsOnIOThread( 517 quota_manager, remove_mask, decrement_callback, 518 origins, quota::kStorageTypeSyncable); 519 } 520 } 521 522 DecrementTaskCountOnIO(); 523 } 524 525 void StoragePartitionImpl::DataDeletionHelper::IncrementTaskCountOnUI() { 526 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 527 ++task_count; 528 } 529 530 void StoragePartitionImpl::DataDeletionHelper::DecrementTaskCountOnUI() { 531 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 532 BrowserThread::PostTask( 533 BrowserThread::UI, FROM_HERE, 534 base::Bind(&DataDeletionHelper::DecrementTaskCountOnUI, 535 base::Unretained(this))); 536 return; 537 } 538 DCHECK_GT(task_count, 0); 539 --task_count; 540 if (!task_count) { 541 callback.Run(); 542 delete this; 543 } 544 } 545 546 void StoragePartitionImpl::DataDeletionHelper::ClearDataOnUIThread( 547 uint32 remove_mask, 548 uint32 quota_storage_remove_mask, 549 const GURL& remove_origin, 550 const base::FilePath& path, 551 net::URLRequestContextGetter* rq_context, 552 DOMStorageContextWrapper* dom_storage_context, 553 quota::QuotaManager* quota_manager, 554 WebRTCIdentityStore* webrtc_identity_store, 555 const base::Time begin, 556 const base::Time end) { 557 DCHECK_NE(remove_mask, 0u); 558 DCHECK(!callback.is_null()); 559 560 IncrementTaskCountOnUI(); 561 base::Closure decrement_callback = base::Bind( 562 &DataDeletionHelper::DecrementTaskCountOnUI, base::Unretained(this)); 563 564 if (remove_mask & REMOVE_DATA_MASK_COOKIES) { 565 // Handle the cookies. 566 IncrementTaskCountOnUI(); 567 BrowserThread::PostTask( 568 BrowserThread::IO, FROM_HERE, 569 base::Bind(&ClearCookiesOnIOThread, 570 make_scoped_refptr(rq_context), begin, end, remove_origin, 571 decrement_callback)); 572 } 573 574 if (remove_mask & REMOVE_DATA_MASK_INDEXEDDB || 575 remove_mask & REMOVE_DATA_MASK_WEBSQL || 576 remove_mask & REMOVE_DATA_MASK_APPCACHE || 577 remove_mask & REMOVE_DATA_MASK_FILE_SYSTEMS) { 578 IncrementTaskCountOnUI(); 579 BrowserThread::PostTask( 580 BrowserThread::IO, FROM_HERE, 581 base::Bind(&ClearQuotaManagedDataOnIOThread, 582 make_scoped_refptr(quota_manager), begin, 583 remove_mask, quota_storage_remove_mask, remove_origin, 584 decrement_callback)); 585 } 586 587 if (remove_mask & REMOVE_DATA_MASK_LOCAL_STORAGE) { 588 IncrementTaskCountOnUI(); 589 ClearLocalStorageOnUIThread( 590 make_scoped_refptr(dom_storage_context), 591 remove_origin, begin, end, decrement_callback); 592 593 // ClearDataImpl cannot clear session storage data when a particular origin 594 // is specified. Therefore we ignore clearing session storage in this case. 595 // TODO(lazyboy): Fix. 596 if (remove_origin.is_empty()) { 597 IncrementTaskCountOnUI(); 598 ClearSessionStorageOnUIThread( 599 make_scoped_refptr(dom_storage_context), decrement_callback); 600 } 601 } 602 603 if (remove_mask & REMOVE_DATA_MASK_SHADER_CACHE) { 604 IncrementTaskCountOnUI(); 605 BrowserThread::PostTask( 606 BrowserThread::IO, FROM_HERE, 607 base::Bind(&ClearShaderCacheOnIOThread, 608 path, begin, end, decrement_callback)); 609 } 610 611 if (remove_mask & REMOVE_DATA_MASK_WEBRTC_IDENTITY) { 612 IncrementTaskCountOnUI(); 613 BrowserThread::PostTask( 614 BrowserThread::IO, 615 FROM_HERE, 616 base::Bind(&WebRTCIdentityStore::DeleteBetween, 617 webrtc_identity_store, 618 begin, 619 end, 620 decrement_callback)); 621 } 622 623 DecrementTaskCountOnUI(); 624 } 625 626 627 void StoragePartitionImpl::ClearDataForOrigin( 628 uint32 remove_mask, 629 uint32 quota_storage_remove_mask, 630 const GURL& storage_origin, 631 net::URLRequestContextGetter* request_context_getter) { 632 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 633 ClearDataImpl(remove_mask, quota_storage_remove_mask, storage_origin, 634 request_context_getter, base::Time(), base::Time::Max(), 635 base::Bind(&base::DoNothing)); 636 } 637 638 void StoragePartitionImpl::ClearDataForUnboundedRange( 639 uint32 remove_mask, 640 uint32 quota_storage_remove_mask) { 641 ClearDataImpl(remove_mask, quota_storage_remove_mask, GURL(), 642 GetURLRequestContext(), base::Time(), base::Time::Max(), 643 base::Bind(&base::DoNothing)); 644 } 645 646 void StoragePartitionImpl::ClearDataForRange(uint32 remove_mask, 647 uint32 quota_storage_remove_mask, 648 const base::Time& begin, 649 const base::Time& end, 650 const base::Closure& callback) { 651 ClearDataImpl(remove_mask, quota_storage_remove_mask, GURL(), 652 GetURLRequestContext(), begin, end, callback); 653 } 654 655 WebRTCIdentityStore* StoragePartitionImpl::GetWebRTCIdentityStore() { 656 return webrtc_identity_store_.get(); 657 } 658 659 void StoragePartitionImpl::SetURLRequestContext( 660 net::URLRequestContextGetter* url_request_context) { 661 url_request_context_ = url_request_context; 662 } 663 664 void StoragePartitionImpl::SetMediaURLRequestContext( 665 net::URLRequestContextGetter* media_url_request_context) { 666 media_url_request_context_ = media_url_request_context; 667 } 668 669 } // namespace content 670