| 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" |
| 11 #include "base/task_runner_util.h" | 11 #include "base/task_runner_util.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/common/pref_names.h" | 13 #include "components/browsing_data/pref_names.h" |
| 14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/browser/storage_partition.h" | 15 #include "content/public/browser/storage_partition.h" |
| 16 #include "storage/browser/fileapi/file_system_context.h" | 16 #include "storage/browser/fileapi/file_system_context.h" |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 // Determining the origins must be run on the file task thread. | 20 // Determining the origins must be run on the file task thread. |
| 21 std::set<GURL> CountOriginsOnFileTaskRunner( | 21 std::set<GURL> CountOriginsOnFileTaskRunner( |
| 22 storage::FileSystemContext* filesystem_context) { | 22 storage::FileSystemContext* filesystem_context) { |
| 23 DCHECK(filesystem_context->default_file_task_runner() | 23 DCHECK(filesystem_context->default_file_task_runner() |
| (...skipping 21 matching lines...) Expand all Loading... |
| 45 } | 45 } |
| 46 | 46 |
| 47 MediaLicensesCounter::MediaLicenseResult::~MediaLicenseResult() {} | 47 MediaLicensesCounter::MediaLicenseResult::~MediaLicenseResult() {} |
| 48 | 48 |
| 49 const std::string& MediaLicensesCounter::MediaLicenseResult::GetOneOrigin() | 49 const std::string& MediaLicensesCounter::MediaLicenseResult::GetOneOrigin() |
| 50 const { | 50 const { |
| 51 return one_origin_; | 51 return one_origin_; |
| 52 } | 52 } |
| 53 | 53 |
| 54 MediaLicensesCounter::MediaLicensesCounter(Profile* profile) | 54 MediaLicensesCounter::MediaLicensesCounter(Profile* profile) |
| 55 : BrowsingDataCounter(prefs::kDeleteMediaLicenses), | 55 : BrowsingDataCounter(browsing_data::prefs::kDeleteMediaLicenses), |
| 56 profile_(profile), | 56 profile_(profile), |
| 57 weak_ptr_factory_(this) {} | 57 weak_ptr_factory_(this) {} |
| 58 | 58 |
| 59 MediaLicensesCounter::~MediaLicensesCounter() {} | 59 MediaLicensesCounter::~MediaLicensesCounter() {} |
| 60 | 60 |
| 61 void MediaLicensesCounter::Count() { | 61 void MediaLicensesCounter::Count() { |
| 62 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 62 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 63 scoped_refptr<storage::FileSystemContext> filesystem_context = | 63 scoped_refptr<storage::FileSystemContext> filesystem_context = |
| 64 make_scoped_refptr( | 64 make_scoped_refptr( |
| 65 content::BrowserContext::GetDefaultStoragePartition(profile_) | 65 content::BrowserContext::GetDefaultStoragePartition(profile_) |
| 66 ->GetFileSystemContext()); | 66 ->GetFileSystemContext()); |
| 67 base::PostTaskAndReplyWithResult( | 67 base::PostTaskAndReplyWithResult( |
| 68 filesystem_context->default_file_task_runner(), FROM_HERE, | 68 filesystem_context->default_file_task_runner(), FROM_HERE, |
| 69 base::Bind(&CountOriginsOnFileTaskRunner, | 69 base::Bind(&CountOriginsOnFileTaskRunner, |
| 70 base::RetainedRef(filesystem_context)), | 70 base::RetainedRef(filesystem_context)), |
| 71 base::Bind(&MediaLicensesCounter::OnContentLicensesObtained, | 71 base::Bind(&MediaLicensesCounter::OnContentLicensesObtained, |
| 72 weak_ptr_factory_.GetWeakPtr())); | 72 weak_ptr_factory_.GetWeakPtr())); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void MediaLicensesCounter::OnContentLicensesObtained( | 75 void MediaLicensesCounter::OnContentLicensesObtained( |
| 76 const std::set<GURL>& origins) { | 76 const std::set<GURL>& origins) { |
| 77 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 77 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 78 ReportResult(base::WrapUnique(new MediaLicenseResult(this, origins))); | 78 ReportResult(base::WrapUnique(new MediaLicenseResult(this, origins))); |
| 79 } | 79 } |
| OLD | NEW |