OLD | NEW |
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 "content/browser/plugin_private_storage_helper.h" | 5 #include "content/browser/plugin_private_storage_helper.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 | 274 |
275 const base::Time begin_; | 275 const base::Time begin_; |
276 const base::Time end_; | 276 const base::Time end_; |
277 const base::Closure callback_; | 277 const base::Closure callback_; |
278 int task_count_ = 0; | 278 int task_count_ = 0; |
279 }; | 279 }; |
280 | 280 |
281 void PluginPrivateDataDeletionHelper::CheckOriginsOnFileTaskRunner( | 281 void PluginPrivateDataDeletionHelper::CheckOriginsOnFileTaskRunner( |
282 const std::set<GURL>& origins) { | 282 const std::set<GURL>& origins) { |
283 DCHECK(filesystem_context_->default_file_task_runner() | 283 DCHECK(filesystem_context_->default_file_task_runner() |
284 ->RunsTasksOnCurrentThread()); | 284 ->RunsTasksInCurrentSequence()); |
285 IncrementTaskCount(); | 285 IncrementTaskCount(); |
286 | 286 |
287 base::Callback<void(bool, const GURL&)> decrement_callback = | 287 base::Callback<void(bool, const GURL&)> decrement_callback = |
288 base::Bind(&PluginPrivateDataDeletionHelper::DecrementTaskCount, | 288 base::Bind(&PluginPrivateDataDeletionHelper::DecrementTaskCount, |
289 base::Unretained(this)); | 289 base::Unretained(this)); |
290 storage::AsyncFileUtil* async_file_util = | 290 storage::AsyncFileUtil* async_file_util = |
291 filesystem_context_->GetAsyncFileUtil( | 291 filesystem_context_->GetAsyncFileUtil( |
292 storage::kFileSystemTypePluginPrivate); | 292 storage::kFileSystemTypePluginPrivate); |
293 storage::ObfuscatedFileUtil* obfuscated_file_util = | 293 storage::ObfuscatedFileUtil* obfuscated_file_util = |
294 static_cast<storage::ObfuscatedFileUtil*>( | 294 static_cast<storage::ObfuscatedFileUtil*>( |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 } | 331 } |
332 | 332 |
333 // Cancels out the call to IncrementTaskCount() at the start of this method. | 333 // Cancels out the call to IncrementTaskCount() at the start of this method. |
334 // If there are no origins specified then this will cause this helper to | 334 // If there are no origins specified then this will cause this helper to |
335 // be destroyed. | 335 // be destroyed. |
336 DecrementTaskCount(false, GURL()); | 336 DecrementTaskCount(false, GURL()); |
337 } | 337 } |
338 | 338 |
339 void PluginPrivateDataDeletionHelper::IncrementTaskCount() { | 339 void PluginPrivateDataDeletionHelper::IncrementTaskCount() { |
340 DCHECK(filesystem_context_->default_file_task_runner() | 340 DCHECK(filesystem_context_->default_file_task_runner() |
341 ->RunsTasksOnCurrentThread()); | 341 ->RunsTasksInCurrentSequence()); |
342 ++task_count_; | 342 ++task_count_; |
343 } | 343 } |
344 | 344 |
345 void PluginPrivateDataDeletionHelper::DecrementTaskCount( | 345 void PluginPrivateDataDeletionHelper::DecrementTaskCount( |
346 bool delete_data_for_origin, | 346 bool delete_data_for_origin, |
347 const GURL& origin) { | 347 const GURL& origin) { |
348 DCHECK(filesystem_context_->default_file_task_runner() | 348 DCHECK(filesystem_context_->default_file_task_runner() |
349 ->RunsTasksOnCurrentThread()); | 349 ->RunsTasksInCurrentSequence()); |
350 | 350 |
351 // Since the PluginPrivateDataByOriginChecker runs on the IO thread, | 351 // Since the PluginPrivateDataByOriginChecker runs on the IO thread, |
352 // delete all the data for |origin| if needed. | 352 // delete all the data for |origin| if needed. |
353 if (delete_data_for_origin) { | 353 if (delete_data_for_origin) { |
354 DCHECK(!origin.is_empty()); | 354 DCHECK(!origin.is_empty()); |
355 DVLOG(3) << "Deleting plugin data for " << origin; | 355 DVLOG(3) << "Deleting plugin data for " << origin; |
356 storage::FileSystemBackend* backend = | 356 storage::FileSystemBackend* backend = |
357 filesystem_context_->GetFileSystemBackend( | 357 filesystem_context_->GetFileSystemBackend( |
358 storage::kFileSystemTypePluginPrivate); | 358 storage::kFileSystemTypePluginPrivate); |
359 storage::FileSystemQuotaUtil* quota_util = backend->GetQuotaUtil(); | 359 storage::FileSystemQuotaUtil* quota_util = backend->GetQuotaUtil(); |
(...skipping 18 matching lines...) Expand all Loading... |
378 | 378 |
379 } // namespace | 379 } // namespace |
380 | 380 |
381 void ClearPluginPrivateDataOnFileTaskRunner( | 381 void ClearPluginPrivateDataOnFileTaskRunner( |
382 scoped_refptr<storage::FileSystemContext> filesystem_context, | 382 scoped_refptr<storage::FileSystemContext> filesystem_context, |
383 const GURL& storage_origin, | 383 const GURL& storage_origin, |
384 const base::Time begin, | 384 const base::Time begin, |
385 const base::Time end, | 385 const base::Time end, |
386 const base::Closure& callback) { | 386 const base::Closure& callback) { |
387 DCHECK(filesystem_context->default_file_task_runner() | 387 DCHECK(filesystem_context->default_file_task_runner() |
388 ->RunsTasksOnCurrentThread()); | 388 ->RunsTasksInCurrentSequence()); |
389 DVLOG(3) << "Clearing plugin data for origin: " << storage_origin; | 389 DVLOG(3) << "Clearing plugin data for origin: " << storage_origin; |
390 | 390 |
391 storage::FileSystemBackend* backend = | 391 storage::FileSystemBackend* backend = |
392 filesystem_context->GetFileSystemBackend( | 392 filesystem_context->GetFileSystemBackend( |
393 storage::kFileSystemTypePluginPrivate); | 393 storage::kFileSystemTypePluginPrivate); |
394 storage::FileSystemQuotaUtil* quota_util = backend->GetQuotaUtil(); | 394 storage::FileSystemQuotaUtil* quota_util = backend->GetQuotaUtil(); |
395 | 395 |
396 // Determine the set of origins used. | 396 // Determine the set of origins used. |
397 std::set<GURL> origins; | 397 std::set<GURL> origins; |
398 quota_util->GetOriginsForTypeOnFileTaskRunner( | 398 quota_util->GetOriginsForTypeOnFileTaskRunner( |
(...skipping 19 matching lines...) Expand all Loading... |
418 origins.insert(storage_origin); | 418 origins.insert(storage_origin); |
419 } | 419 } |
420 | 420 |
421 PluginPrivateDataDeletionHelper* helper = new PluginPrivateDataDeletionHelper( | 421 PluginPrivateDataDeletionHelper* helper = new PluginPrivateDataDeletionHelper( |
422 std::move(filesystem_context), begin, end, callback); | 422 std::move(filesystem_context), begin, end, callback); |
423 helper->CheckOriginsOnFileTaskRunner(origins); | 423 helper->CheckOriginsOnFileTaskRunner(origins); |
424 // |helper| will delete itself when all origins have been checked. | 424 // |helper| will delete itself when all origins have been checked. |
425 } | 425 } |
426 | 426 |
427 } // namespace content | 427 } // namespace content |
OLD | NEW |