| 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 "chrome/browser/browsing_data/media_licenses_counter.h" | 5 #include "chrome/browser/browsing_data/media_licenses_counter.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 weak_ptr_factory_(this) {} | 56 weak_ptr_factory_(this) {} |
| 57 | 57 |
| 58 MediaLicensesCounter::~MediaLicensesCounter() {} | 58 MediaLicensesCounter::~MediaLicensesCounter() {} |
| 59 | 59 |
| 60 const char* MediaLicensesCounter::GetPrefName() const { | 60 const char* MediaLicensesCounter::GetPrefName() const { |
| 61 return browsing_data::prefs::kDeleteMediaLicenses; | 61 return browsing_data::prefs::kDeleteMediaLicenses; |
| 62 } | 62 } |
| 63 | 63 |
| 64 void MediaLicensesCounter::Count() { | 64 void MediaLicensesCounter::Count() { |
| 65 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 65 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 66 // Cancel existing requests. |
| 67 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 66 scoped_refptr<storage::FileSystemContext> filesystem_context = | 68 scoped_refptr<storage::FileSystemContext> filesystem_context = |
| 67 make_scoped_refptr( | 69 make_scoped_refptr( |
| 68 content::BrowserContext::GetDefaultStoragePartition(profile_) | 70 content::BrowserContext::GetDefaultStoragePartition(profile_) |
| 69 ->GetFileSystemContext()); | 71 ->GetFileSystemContext()); |
| 70 base::PostTaskAndReplyWithResult( | 72 base::PostTaskAndReplyWithResult( |
| 71 filesystem_context->default_file_task_runner(), FROM_HERE, | 73 filesystem_context->default_file_task_runner(), FROM_HERE, |
| 72 base::Bind(&CountOriginsOnFileTaskRunner, | 74 base::Bind(&CountOriginsOnFileTaskRunner, |
| 73 base::RetainedRef(filesystem_context)), | 75 base::RetainedRef(filesystem_context)), |
| 74 base::Bind(&MediaLicensesCounter::OnContentLicensesObtained, | 76 base::Bind(&MediaLicensesCounter::OnContentLicensesObtained, |
| 75 weak_ptr_factory_.GetWeakPtr())); | 77 weak_ptr_factory_.GetWeakPtr())); |
| 76 } | 78 } |
| 77 | 79 |
| 78 void MediaLicensesCounter::OnContentLicensesObtained( | 80 void MediaLicensesCounter::OnContentLicensesObtained( |
| 79 const std::set<GURL>& origins) { | 81 const std::set<GURL>& origins) { |
| 80 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 82 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 81 ReportResult(base::MakeUnique<MediaLicenseResult>(this, origins)); | 83 ReportResult(base::MakeUnique<MediaLicenseResult>(this, origins)); |
| 82 } | 84 } |
| OLD | NEW |