Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/storage_partition_impl.h" | 5 #include "content/browser/storage_partition_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/sequenced_task_runner.h" | 14 #include "base/sequenced_task_runner.h" |
| 15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 16 #include "base/stl_util.h" | |
| 16 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 17 #include "content/browser/browser_main_loop.h" | 18 #include "content/browser/browser_main_loop.h" |
| 18 #include "content/browser/fileapi/browser_file_system_helper.h" | 19 #include "content/browser/fileapi/browser_file_system_helper.h" |
| 19 #include "content/browser/geofencing/geofencing_manager.h" | 20 #include "content/browser/geofencing/geofencing_manager.h" |
| 20 #include "content/browser/gpu/shader_disk_cache.h" | 21 #include "content/browser/gpu/shader_disk_cache.h" |
| 21 #include "content/browser/host_zoom_map_impl.h" | 22 #include "content/browser/host_zoom_map_impl.h" |
| 22 #include "content/browser/notifications/platform_notification_context_impl.h" | 23 #include "content/browser/notifications/platform_notification_context_impl.h" |
| 23 #include "content/common/dom_storage/dom_storage_types.h" | 24 #include "content/common/dom_storage/dom_storage_types.h" |
| 24 #include "content/public/browser/browser_context.h" | 25 #include "content/public/browser/browser_context.h" |
| 25 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
| 26 #include "content/public/browser/dom_storage_context.h" | 27 #include "content/public/browser/dom_storage_context.h" |
| 27 #include "content/public/browser/indexed_db_context.h" | 28 #include "content/public/browser/indexed_db_context.h" |
| 28 #include "content/public/browser/local_storage_usage_info.h" | 29 #include "content/public/browser/local_storage_usage_info.h" |
| 29 #include "content/public/browser/session_storage_usage_info.h" | 30 #include "content/public/browser/session_storage_usage_info.h" |
| 30 #include "net/base/completion_callback.h" | 31 #include "net/base/completion_callback.h" |
| 31 #include "net/base/net_errors.h" | 32 #include "net/base/net_errors.h" |
| 32 #include "net/cookies/canonical_cookie.h" | 33 #include "net/cookies/canonical_cookie.h" |
| 33 #include "net/cookies/cookie_monster.h" | 34 #include "net/cookies/cookie_monster.h" |
| 34 #include "net/url_request/url_request_context.h" | 35 #include "net/url_request/url_request_context.h" |
| 35 #include "net/url_request/url_request_context_getter.h" | 36 #include "net/url_request/url_request_context_getter.h" |
| 37 #include "ppapi/shared_impl/ppapi_constants.h" | |
| 36 #include "storage/browser/database/database_tracker.h" | 38 #include "storage/browser/database/database_tracker.h" |
| 37 #include "storage/browser/quota/quota_manager.h" | 39 #include "storage/browser/quota/quota_manager.h" |
| 38 | 40 |
| 41 #if defined(ENABLE_PLUGINS) | |
| 42 #include "base/files/file_enumerator.h" | |
| 43 #include "storage/browser/fileapi/async_file_util.h" | |
| 44 #include "storage/browser/fileapi/async_file_util_adapter.h" | |
| 45 #include "storage/browser/fileapi/isolated_context.h" | |
| 46 #include "storage/browser/fileapi/obfuscated_file_util.h" | |
| 47 #include "storage/common/fileapi/file_system_util.h" | |
| 48 #endif // defined(ENABLE_PLUGINS) | |
| 49 | |
| 39 namespace content { | 50 namespace content { |
| 40 | 51 |
| 41 namespace { | 52 namespace { |
| 42 | 53 |
| 43 bool DoesCookieMatchHost(const std::string& host, | 54 bool DoesCookieMatchHost(const std::string& host, |
| 44 const net::CanonicalCookie& cookie) { | 55 const net::CanonicalCookie& cookie) { |
| 45 return cookie.IsHostCookie() && cookie.IsDomainMatch(host); | 56 return cookie.IsHostCookie() && cookie.IsDomainMatch(host); |
| 46 } | 57 } |
| 47 | 58 |
| 48 void OnClearedCookies(const base::Closure& callback, int num_deleted) { | 59 void OnClearedCookies(const base::Closure& callback, int num_deleted) { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 const StoragePartition::OriginMatcherFunction& origin_matcher, | 219 const StoragePartition::OriginMatcherFunction& origin_matcher, |
| 209 const base::Closure& callback) { | 220 const base::Closure& callback) { |
| 210 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 221 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 211 | 222 |
| 212 dom_storage_context->GetSessionStorageUsage( | 223 dom_storage_context->GetSessionStorageUsage( |
| 213 base::Bind(&OnSessionStorageUsageInfo, dom_storage_context, | 224 base::Bind(&OnSessionStorageUsageInfo, dom_storage_context, |
| 214 special_storage_policy, origin_matcher, | 225 special_storage_policy, origin_matcher, |
| 215 callback)); | 226 callback)); |
| 216 } | 227 } |
| 217 | 228 |
| 229 #if defined(ENABLE_PLUGINS) | |
| 230 // Helper for deleting plugin private data for a specified origin and plugin. | |
| 231 // If any file matches the time range specified, then all files for this | |
| 232 // origin and plugin are deleted. | |
| 233 // All of the operations in this class are done on the FILE thread. | |
| 234 class PluginPrivateDataByOriginDeletionHelper { | |
| 235 public: | |
| 236 PluginPrivateDataByOriginDeletionHelper( | |
| 237 storage::FileSystemContext* filesystem_context, | |
| 238 const GURL& origin, | |
| 239 const std::string& plugin_name, | |
| 240 const base::Time begin, | |
| 241 const base::Time end, | |
| 242 const base::Closure& callback) | |
| 243 : filesystem_context_(filesystem_context), | |
| 244 origin_(origin), | |
| 245 plugin_name_(plugin_name), | |
| 246 begin_(begin), | |
| 247 end_(end), | |
| 248 callback_(callback) { | |
| 249 // Create the filesystem ID. | |
| 250 fsid_ = storage::IsolatedContext::GetInstance() | |
| 251 ->RegisterFileSystemForVirtualPath( | |
| 252 storage::kFileSystemTypePluginPrivate, | |
| 253 ppapi::kPluginPrivateRootName, base::FilePath()); | |
| 254 } | |
| 255 ~PluginPrivateDataByOriginDeletionHelper() {} | |
| 256 | |
| 257 // Checks the files contained in the plugin private filesystem for |origin_| | |
| 258 // and |plugin_name_| and deletes any files whose last modified time is | |
| 259 // greater or equal to |begin_|. |callback_| is called when all actions | |
| 260 // are complete. | |
| 261 void Start(); | |
| 262 | |
| 263 private: | |
| 264 void OnFileSystemOpened(base::File::Error result); | |
| 265 void OnDirectoryRead(const std::string& root, | |
| 266 base::File::Error result, | |
| 267 const storage::AsyncFileUtil::EntryList& file_list, | |
| 268 bool has_more); | |
| 269 void OnFileInfo(const std::string& file_name, | |
| 270 const storage::FileSystemURL& file_url, | |
| 271 base::File::Error result, | |
| 272 const base::File::Info& file_info); | |
| 273 | |
| 274 // Keeps track of the pending work. When |task_count_| goes to 0 then | |
| 275 // |callback_| is called and this helper object is destroyed. | |
| 276 void IncrementTaskCount(); | |
| 277 void DecrementTaskCount(); | |
| 278 | |
| 279 // Not owned by this object. Caller is responsible for keeping the | |
| 280 // FileSystemContext alive until |callback_| is called. | |
| 281 storage::FileSystemContext* filesystem_context_; | |
| 282 | |
| 283 GURL origin_; | |
| 284 std::string plugin_name_; | |
| 285 base::Time begin_; | |
| 286 base::Time end_; | |
|
nhiroki
2016/05/24 01:40:03
Could you add 'const' to these fields?
jrummell
2016/05/24 22:15:33
Done.
| |
| 287 base::Closure callback_; | |
| 288 std::string fsid_; | |
| 289 int task_count_ = 0; | |
| 290 bool delete_this_data_ = false; | |
| 291 }; | |
| 292 | |
| 293 void PluginPrivateDataByOriginDeletionHelper::Start() { | |
| 294 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | |
| 295 DCHECK(storage::ValidateIsolatedFileSystemId(fsid_)); | |
| 296 | |
| 297 IncrementTaskCount(); | |
| 298 filesystem_context_->OpenPluginPrivateFileSystem( | |
| 299 origin_, storage::kFileSystemTypePluginPrivate, fsid_, plugin_name_, | |
| 300 storage::OPEN_FILE_SYSTEM_FAIL_IF_NONEXISTENT, | |
| 301 base::Bind(&PluginPrivateDataByOriginDeletionHelper::OnFileSystemOpened, | |
| 302 base::Unretained(this))); | |
| 303 } | |
| 304 | |
| 305 void PluginPrivateDataByOriginDeletionHelper::OnFileSystemOpened( | |
| 306 base::File::Error result) { | |
| 307 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | |
| 308 DVLOG(3) << "Opened filesystem for " << origin_ << ":" << plugin_name_ | |
| 309 << ", result: " << result; | |
| 310 | |
| 311 // If we can't open the directory, we can't delete files so simply return. | |
| 312 if (result != base::File::FILE_OK) { | |
| 313 DecrementTaskCount(); | |
| 314 return; | |
| 315 } | |
| 316 | |
| 317 storage::AsyncFileUtil* file_util = filesystem_context_->GetAsyncFileUtil( | |
| 318 storage::kFileSystemTypePluginPrivate); | |
| 319 std::string root = storage::GetIsolatedFileSystemRootURIString( | |
| 320 origin_, fsid_, ppapi::kPluginPrivateRootName); | |
| 321 std::unique_ptr<storage::FileSystemOperationContext> operation_context = | |
| 322 base::WrapUnique( | |
| 323 new storage::FileSystemOperationContext(filesystem_context_)); | |
| 324 file_util->ReadDirectory( | |
| 325 std::move(operation_context), filesystem_context_->CrackURL(GURL(root)), | |
| 326 base::Bind(&PluginPrivateDataByOriginDeletionHelper::OnDirectoryRead, | |
| 327 base::Unretained(this), root)); | |
| 328 } | |
| 329 | |
| 330 void PluginPrivateDataByOriginDeletionHelper::OnDirectoryRead( | |
| 331 const std::string& root, | |
| 332 base::File::Error result, | |
| 333 const storage::AsyncFileUtil::EntryList& file_list, | |
| 334 bool has_more) { | |
| 335 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | |
| 336 DVLOG(3) << __FUNCTION__ << " result: " << result | |
| 337 << ", #files: " << file_list.size(); | |
| 338 | |
| 339 // Quit if there is an error. | |
| 340 if (result != base::File::FILE_OK) { | |
| 341 DLOG(ERROR) << "Unable to read directory for " << origin_ << ":" | |
| 342 << plugin_name_; | |
| 343 DecrementTaskCount(); | |
| 344 return; | |
| 345 } | |
|
nhiroki
2016/05/24 01:40:03
You might want to skip remaining tasks if |delete_
jrummell
2016/05/24 22:15:33
Done. Not sure if it will help right now, as typic
| |
| 346 | |
| 347 // No error, process the files returned. | |
| 348 storage::AsyncFileUtil* file_util = filesystem_context_->GetAsyncFileUtil( | |
| 349 storage::kFileSystemTypePluginPrivate); | |
| 350 for (const auto& file : file_list) { | |
| 351 DVLOG(3) << __FUNCTION__ << " file: " << file.name; | |
| 352 DCHECK(!file.is_directory); // Nested directories not implemented. | |
| 353 | |
| 354 std::unique_ptr<storage::FileSystemOperationContext> operation_context = | |
| 355 base::WrapUnique( | |
| 356 new storage::FileSystemOperationContext(filesystem_context_)); | |
| 357 storage::FileSystemURL file_url = | |
| 358 filesystem_context_->CrackURL(GURL(root + file.name)); | |
| 359 IncrementTaskCount(); | |
| 360 file_util->GetFileInfo( | |
| 361 std::move(operation_context), file_url, | |
| 362 storage::FileSystemOperation::GET_METADATA_FIELD_SIZE | | |
| 363 storage::FileSystemOperation::GET_METADATA_FIELD_LAST_MODIFIED, | |
| 364 base::Bind(&PluginPrivateDataByOriginDeletionHelper::OnFileInfo, | |
| 365 base::Unretained(this), file.name, file_url)); | |
|
nhiroki
2016/05/24 01:40:03
You can just stop passing |file_url| here.
jrummell
2016/05/24 22:15:33
Done.
| |
| 366 } | |
| 367 | |
| 368 // If there are more files in this directory, wait for the next call. | |
| 369 if (has_more) | |
| 370 return; | |
| 371 | |
| 372 DecrementTaskCount(); | |
| 373 } | |
| 374 | |
| 375 void PluginPrivateDataByOriginDeletionHelper::OnFileInfo( | |
| 376 const std::string& file_name, | |
| 377 const storage::FileSystemURL& /* file_url */, | |
| 378 base::File::Error result, | |
| 379 const base::File::Info& file_info) { | |
| 380 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | |
| 381 | |
| 382 if (result == base::File::FILE_OK) { | |
| 383 DVLOG(3) << __FUNCTION__ << " name: " << file_name | |
| 384 << ", size: " << file_info.size | |
| 385 << ", modified: " << file_info.last_modified; | |
| 386 if (file_info.last_modified >= begin_ && file_info.last_modified <= end_) | |
| 387 delete_this_data_ = true; | |
|
nhiroki
2016/05/24 01:40:03
|delete_this_data_| would sound a bit confusing to
jrummell
2016/05/24 22:15:33
Done.
| |
| 388 } | |
| 389 | |
| 390 DecrementTaskCount(); | |
| 391 } | |
| 392 | |
| 393 void PluginPrivateDataByOriginDeletionHelper::IncrementTaskCount() { | |
| 394 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | |
| 395 ++task_count_; | |
| 396 } | |
| 397 | |
| 398 void PluginPrivateDataByOriginDeletionHelper::DecrementTaskCount() { | |
| 399 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | |
| 400 DCHECK_GT(task_count_, 0); | |
| 401 --task_count_; | |
| 402 if (task_count_) | |
| 403 return; | |
| 404 | |
| 405 // If there are no more tasks in progress, then delete the files for this | |
| 406 // origin if necessary. | |
| 407 if (delete_this_data_) { | |
| 408 DVLOG(3) << "Deleting plugin data for " << origin_ << ":" << plugin_name_; | |
| 409 storage::FileSystemBackend* backend = | |
| 410 filesystem_context_->GetFileSystemBackend( | |
| 411 storage::kFileSystemTypePluginPrivate); | |
| 412 storage::FileSystemQuotaUtil* quota_util = backend->GetQuotaUtil(); | |
| 413 base::File::Error result = quota_util->DeleteOriginDataOnFileTaskRunner( | |
| 414 filesystem_context_, nullptr, origin_, | |
| 415 storage::kFileSystemTypePluginPrivate); | |
| 416 DLOG_IF(ERROR, result != base::File::FILE_OK) | |
| 417 << "Unable to delete the plugin data for " << origin_ << ":" | |
| 418 << plugin_name_; | |
| 419 } | |
| 420 | |
| 421 // Run |callback_| and then this helper can be deleted. | |
| 422 callback_.Run(); | |
| 423 delete this; | |
| 424 } | |
| 425 | |
| 426 // Helper for deleting the plugin private data. | |
| 427 // All of the operations in this class are done on the FILE thread. | |
| 428 class PluginPrivateDataDeletionHelper { | |
| 429 public: | |
| 430 PluginPrivateDataDeletionHelper( | |
| 431 scoped_refptr<storage::FileSystemContext> filesystem_context, | |
| 432 const base::Time begin, | |
| 433 const base::Time end, | |
| 434 const base::Closure& callback) | |
| 435 : filesystem_context_(filesystem_context), | |
|
nhiroki
2016/05/24 01:40:03
std::move(filesystem_context) because the context
jrummell
2016/05/24 22:15:33
Done.
| |
| 436 begin_(begin), | |
| 437 end_(end), | |
| 438 callback_(callback) {} | |
| 439 ~PluginPrivateDataDeletionHelper() {} | |
| 440 | |
| 441 void CheckOrigins(const std::set<GURL>& origins); | |
| 442 | |
| 443 private: | |
| 444 // Keeps track of the pending work. When |task_count_| goes to 0 then | |
| 445 // |callback_| is called and this helper object is destroyed. | |
| 446 void IncrementTaskCount(); | |
| 447 void DecrementTaskCount(); | |
| 448 | |
| 449 // Keep a reference to FileSystemContext until we are done with it. | |
| 450 scoped_refptr<storage::FileSystemContext> filesystem_context_; | |
| 451 | |
| 452 base::Time begin_; | |
| 453 base::Time end_; | |
|
nhiroki
2016/05/24 01:40:03
Could you add 'const' to these fields?
jrummell
2016/05/24 22:15:33
Done.
| |
| 454 base::Closure callback_; | |
| 455 int task_count_ = 0; | |
| 456 }; | |
| 457 | |
| 458 void PluginPrivateDataDeletionHelper::CheckOrigins( | |
| 459 const std::set<GURL>& origins) { | |
| 460 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | |
| 461 IncrementTaskCount(); | |
| 462 | |
| 463 base::Closure decrement_callback = | |
| 464 base::Bind(&PluginPrivateDataDeletionHelper::DecrementTaskCount, | |
| 465 base::Unretained(this)); | |
| 466 storage::AsyncFileUtil* async_file_util = | |
| 467 filesystem_context_->GetAsyncFileUtil( | |
| 468 storage::kFileSystemTypePluginPrivate); | |
| 469 storage::ObfuscatedFileUtil* obfuscated_file_util = | |
| 470 static_cast<storage::ObfuscatedFileUtil*>( | |
| 471 static_cast<storage::AsyncFileUtilAdapter*>(async_file_util) | |
| 472 ->sync_file_util()); | |
| 473 for (const auto& origin : origins) { | |
| 474 // Determine the available directories for this origin. | |
|
nhiroki
2016/05/24 01:40:03
"available plugin private filesystems" would be cl
jrummell
2016/05/24 22:15:33
Done.
| |
| 475 base::File::Error error; | |
| 476 base::FilePath path = obfuscated_file_util->GetDirectoryForOriginAndType( | |
| 477 origin, "", false, &error); | |
| 478 if (error != base::File::FILE_OK) { | |
| 479 DLOG(ERROR) << "Unable to read directory for " << origin; | |
| 480 continue; | |
| 481 } | |
| 482 base::FileEnumerator file_enumerator(path, false, | |
|
nhiroki
2016/05/24 01:40:03
Could you add comments about why we iterate all di
jrummell
2016/05/24 22:15:33
Done.
| |
| 483 base::FileEnumerator::DIRECTORIES); | |
| 484 for (base::FilePath plugin_path = file_enumerator.Next(); | |
| 485 !plugin_path.empty(); plugin_path = file_enumerator.Next()) { | |
| 486 IncrementTaskCount(); | |
| 487 PluginPrivateDataByOriginDeletionHelper* helper = | |
| 488 new PluginPrivateDataByOriginDeletionHelper( | |
| 489 filesystem_context_.get(), origin.GetOrigin(), | |
| 490 plugin_path.BaseName().MaybeAsASCII(), begin_, end_, | |
| 491 decrement_callback); | |
| 492 helper->Start(); | |
| 493 // |helper| will delete itself when it is done. | |
| 494 } | |
| 495 } | |
| 496 | |
| 497 // Cancels out the call to IncrementTaskCount() at the start of this method. | |
| 498 // If there are no origins specified then this will cause this helper to | |
| 499 // be destroyed. | |
| 500 DecrementTaskCount(); | |
| 501 } | |
| 502 | |
| 503 void PluginPrivateDataDeletionHelper::IncrementTaskCount() { | |
| 504 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | |
| 505 ++task_count_; | |
| 506 } | |
| 507 | |
| 508 void PluginPrivateDataDeletionHelper::DecrementTaskCount() { | |
| 509 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | |
| 510 DCHECK_GT(task_count_, 0); | |
| 511 --task_count_; | |
| 512 if (task_count_) | |
| 513 return; | |
| 514 | |
| 515 // If there are no more tasks in progress, run |callback_| and then | |
| 516 // this helper can be deleted. | |
| 517 callback_.Run(); | |
| 518 delete this; | |
| 519 } | |
| 520 | |
| 521 void ClearPluginPrivateDataOnFileThread( | |
| 522 scoped_refptr<storage::FileSystemContext> filesystem_context, | |
| 523 const GURL& storage_origin, | |
| 524 const base::Time begin, | |
| 525 const base::Time end, | |
| 526 const base::Closure& callback) { | |
| 527 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | |
| 528 DVLOG(3) << "Clearing plugin data for origin: " << storage_origin; | |
| 529 | |
| 530 storage::FileSystemBackend* backend = | |
| 531 filesystem_context->GetFileSystemBackend( | |
| 532 storage::kFileSystemTypePluginPrivate); | |
| 533 storage::FileSystemQuotaUtil* quota_util = backend->GetQuotaUtil(); | |
| 534 | |
| 535 // Determine the set of origins used. | |
| 536 std::set<GURL> origins; | |
| 537 quota_util->GetOriginsForTypeOnFileTaskRunner( | |
| 538 storage::kFileSystemTypePluginPrivate, &origins); | |
| 539 | |
| 540 if (origins.empty()) { | |
| 541 // No origins, so nothing to do. | |
| 542 callback.Run(); | |
| 543 return; | |
| 544 } | |
| 545 | |
| 546 // If a specific origin is provided, then check that it is in the list | |
| 547 // returned and remove all the other origins. | |
| 548 if (!storage_origin.is_empty()) { | |
| 549 if (!ContainsKey(origins, storage_origin)) { | |
| 550 // Nothing matches, so nothing to do. | |
| 551 callback.Run(); | |
| 552 return; | |
| 553 } | |
| 554 | |
| 555 // List should only contain the one value that matches. | |
| 556 origins.clear(); | |
| 557 origins.insert(storage_origin); | |
| 558 } | |
| 559 | |
| 560 PluginPrivateDataDeletionHelper* helper = new PluginPrivateDataDeletionHelper( | |
| 561 std::move(filesystem_context), begin, end, callback); | |
| 562 helper->CheckOrigins(origins); | |
| 563 // |helper| will delete itself when all origins have been checked. | |
| 564 } | |
| 565 #endif // defined(ENABLE_PLUGINS) | |
| 566 | |
| 218 } // namespace | 567 } // namespace |
| 219 | 568 |
| 220 // Static. | 569 // Static. |
| 221 int StoragePartitionImpl::GenerateQuotaClientMask(uint32_t remove_mask) { | 570 int StoragePartitionImpl::GenerateQuotaClientMask(uint32_t remove_mask) { |
| 222 int quota_client_mask = 0; | 571 int quota_client_mask = 0; |
| 223 | 572 |
| 224 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS) | 573 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS) |
| 225 quota_client_mask |= storage::QuotaClient::kFileSystem; | 574 quota_client_mask |= storage::QuotaClient::kFileSystem; |
| 226 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_WEBSQL) | 575 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_WEBSQL) |
| 227 quota_client_mask |= storage::QuotaClient::kDatabase; | 576 quota_client_mask |= storage::QuotaClient::kDatabase; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 void ClearDataOnUIThread( | 658 void ClearDataOnUIThread( |
| 310 const GURL& storage_origin, | 659 const GURL& storage_origin, |
| 311 const OriginMatcherFunction& origin_matcher, | 660 const OriginMatcherFunction& origin_matcher, |
| 312 const CookieMatcherFunction& cookie_matcher, | 661 const CookieMatcherFunction& cookie_matcher, |
| 313 const base::FilePath& path, | 662 const base::FilePath& path, |
| 314 net::URLRequestContextGetter* rq_context, | 663 net::URLRequestContextGetter* rq_context, |
| 315 DOMStorageContextWrapper* dom_storage_context, | 664 DOMStorageContextWrapper* dom_storage_context, |
| 316 storage::QuotaManager* quota_manager, | 665 storage::QuotaManager* quota_manager, |
| 317 storage::SpecialStoragePolicy* special_storage_policy, | 666 storage::SpecialStoragePolicy* special_storage_policy, |
| 318 WebRTCIdentityStore* webrtc_identity_store, | 667 WebRTCIdentityStore* webrtc_identity_store, |
| 668 storage::FileSystemContext* filesystem_context, | |
| 319 const base::Time begin, | 669 const base::Time begin, |
| 320 const base::Time end); | 670 const base::Time end); |
| 321 | 671 |
| 322 void ClearQuotaManagedDataOnIOThread( | 672 void ClearQuotaManagedDataOnIOThread( |
| 323 const scoped_refptr<storage::QuotaManager>& quota_manager, | 673 const scoped_refptr<storage::QuotaManager>& quota_manager, |
| 324 const base::Time begin, | 674 const base::Time begin, |
| 325 const GURL& storage_origin, | 675 const GURL& storage_origin, |
| 326 const scoped_refptr<storage::SpecialStoragePolicy>& | 676 const scoped_refptr<storage::SpecialStoragePolicy>& |
| 327 special_storage_policy, | 677 special_storage_policy, |
| 328 const StoragePartition::OriginMatcherFunction& origin_matcher, | 678 const StoragePartition::OriginMatcherFunction& origin_matcher, |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 628 const base::Closure& callback) { | 978 const base::Closure& callback) { |
| 629 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 979 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 630 DataDeletionHelper* helper = new DataDeletionHelper(remove_mask, | 980 DataDeletionHelper* helper = new DataDeletionHelper(remove_mask, |
| 631 quota_storage_remove_mask, | 981 quota_storage_remove_mask, |
| 632 callback); | 982 callback); |
| 633 // |helper| deletes itself when done in | 983 // |helper| deletes itself when done in |
| 634 // DataDeletionHelper::DecrementTaskCountOnUI(). | 984 // DataDeletionHelper::DecrementTaskCountOnUI(). |
| 635 helper->ClearDataOnUIThread( | 985 helper->ClearDataOnUIThread( |
| 636 storage_origin, origin_matcher, cookie_matcher, GetPath(), rq_context, | 986 storage_origin, origin_matcher, cookie_matcher, GetPath(), rq_context, |
| 637 dom_storage_context_.get(), quota_manager_.get(), | 987 dom_storage_context_.get(), quota_manager_.get(), |
| 638 special_storage_policy_.get(), webrtc_identity_store_.get(), begin, end); | 988 special_storage_policy_.get(), webrtc_identity_store_.get(), |
| 989 filesystem_context_.get(), begin, end); | |
| 639 } | 990 } |
| 640 | 991 |
| 641 void StoragePartitionImpl:: | 992 void StoragePartitionImpl:: |
| 642 QuotaManagedDataDeletionHelper::IncrementTaskCountOnIO() { | 993 QuotaManagedDataDeletionHelper::IncrementTaskCountOnIO() { |
| 643 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 994 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 644 ++task_count; | 995 ++task_count; |
| 645 } | 996 } |
| 646 | 997 |
| 647 void StoragePartitionImpl:: | 998 void StoragePartitionImpl:: |
| 648 QuotaManagedDataDeletionHelper::DecrementTaskCountOnIO() { | 999 QuotaManagedDataDeletionHelper::DecrementTaskCountOnIO() { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 768 void StoragePartitionImpl::DataDeletionHelper::ClearDataOnUIThread( | 1119 void StoragePartitionImpl::DataDeletionHelper::ClearDataOnUIThread( |
| 769 const GURL& storage_origin, | 1120 const GURL& storage_origin, |
| 770 const OriginMatcherFunction& origin_matcher, | 1121 const OriginMatcherFunction& origin_matcher, |
| 771 const CookieMatcherFunction& cookie_matcher, | 1122 const CookieMatcherFunction& cookie_matcher, |
| 772 const base::FilePath& path, | 1123 const base::FilePath& path, |
| 773 net::URLRequestContextGetter* rq_context, | 1124 net::URLRequestContextGetter* rq_context, |
| 774 DOMStorageContextWrapper* dom_storage_context, | 1125 DOMStorageContextWrapper* dom_storage_context, |
| 775 storage::QuotaManager* quota_manager, | 1126 storage::QuotaManager* quota_manager, |
| 776 storage::SpecialStoragePolicy* special_storage_policy, | 1127 storage::SpecialStoragePolicy* special_storage_policy, |
| 777 WebRTCIdentityStore* webrtc_identity_store, | 1128 WebRTCIdentityStore* webrtc_identity_store, |
| 1129 storage::FileSystemContext* filesystem_context, | |
| 778 const base::Time begin, | 1130 const base::Time begin, |
| 779 const base::Time end) { | 1131 const base::Time end) { |
| 780 DCHECK_NE(remove_mask, 0u); | 1132 DCHECK_NE(remove_mask, 0u); |
| 781 DCHECK(!callback.is_null()); | 1133 DCHECK(!callback.is_null()); |
| 782 | 1134 |
| 783 IncrementTaskCountOnUI(); | 1135 IncrementTaskCountOnUI(); |
| 784 base::Closure decrement_callback = base::Bind( | 1136 base::Closure decrement_callback = base::Bind( |
| 785 &DataDeletionHelper::DecrementTaskCountOnUI, base::Unretained(this)); | 1137 &DataDeletionHelper::DecrementTaskCountOnUI, base::Unretained(this)); |
| 786 | 1138 |
| 787 if (remove_mask & REMOVE_DATA_MASK_COOKIES) { | 1139 if (remove_mask & REMOVE_DATA_MASK_COOKIES) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 848 BrowserThread::PostTask( | 1200 BrowserThread::PostTask( |
| 849 BrowserThread::IO, | 1201 BrowserThread::IO, |
| 850 FROM_HERE, | 1202 FROM_HERE, |
| 851 base::Bind(&WebRTCIdentityStore::DeleteBetween, | 1203 base::Bind(&WebRTCIdentityStore::DeleteBetween, |
| 852 webrtc_identity_store, | 1204 webrtc_identity_store, |
| 853 begin, | 1205 begin, |
| 854 end, | 1206 end, |
| 855 decrement_callback)); | 1207 decrement_callback)); |
| 856 } | 1208 } |
| 857 | 1209 |
| 1210 #if defined(ENABLE_PLUGINS) | |
| 1211 if (remove_mask & REMOVE_DATA_MASK_PLUGIN_PRIVATE_DATA) { | |
| 1212 IncrementTaskCountOnUI(); | |
| 1213 BrowserThread::PostTask( | |
| 1214 BrowserThread::FILE, FROM_HERE, | |
| 1215 base::Bind(&ClearPluginPrivateDataOnFileThread, | |
| 1216 make_scoped_refptr(filesystem_context), storage_origin, | |
| 1217 begin, end, decrement_callback)); | |
| 1218 } | |
| 1219 #endif // defined(ENABLE_PLUGINS) | |
| 1220 | |
| 858 DecrementTaskCountOnUI(); | 1221 DecrementTaskCountOnUI(); |
| 859 } | 1222 } |
| 860 | 1223 |
| 861 void StoragePartitionImpl::ClearDataForOrigin( | 1224 void StoragePartitionImpl::ClearDataForOrigin( |
| 862 uint32_t remove_mask, | 1225 uint32_t remove_mask, |
| 863 uint32_t quota_storage_remove_mask, | 1226 uint32_t quota_storage_remove_mask, |
| 864 const GURL& storage_origin, | 1227 const GURL& storage_origin, |
| 865 net::URLRequestContextGetter* request_context_getter, | 1228 net::URLRequestContextGetter* request_context_getter, |
| 866 const base::Closure& callback) { | 1229 const base::Closure& callback) { |
| 867 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1230 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 929 net::URLRequestContextGetter* url_request_context) { | 1292 net::URLRequestContextGetter* url_request_context) { |
| 930 url_request_context_ = url_request_context; | 1293 url_request_context_ = url_request_context; |
| 931 } | 1294 } |
| 932 | 1295 |
| 933 void StoragePartitionImpl::SetMediaURLRequestContext( | 1296 void StoragePartitionImpl::SetMediaURLRequestContext( |
| 934 net::URLRequestContextGetter* media_url_request_context) { | 1297 net::URLRequestContextGetter* media_url_request_context) { |
| 935 media_url_request_context_ = media_url_request_context; | 1298 media_url_request_context_ = media_url_request_context; |
| 936 } | 1299 } |
| 937 | 1300 |
| 938 } // namespace content | 1301 } // namespace content |
| OLD | NEW |