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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after 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(browsing_data::prefs::kDeleteMediaLicenses), | 55 : pref_name_(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 const std::string& MediaLicensesCounter::GetPrefName() const { |
| 62 return pref_name_; |
| 63 } |
| 64 |
61 void MediaLicensesCounter::Count() { | 65 void MediaLicensesCounter::Count() { |
62 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 66 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
63 scoped_refptr<storage::FileSystemContext> filesystem_context = | 67 scoped_refptr<storage::FileSystemContext> filesystem_context = |
64 make_scoped_refptr( | 68 make_scoped_refptr( |
65 content::BrowserContext::GetDefaultStoragePartition(profile_) | 69 content::BrowserContext::GetDefaultStoragePartition(profile_) |
66 ->GetFileSystemContext()); | 70 ->GetFileSystemContext()); |
67 base::PostTaskAndReplyWithResult( | 71 base::PostTaskAndReplyWithResult( |
68 filesystem_context->default_file_task_runner(), FROM_HERE, | 72 filesystem_context->default_file_task_runner(), FROM_HERE, |
69 base::Bind(&CountOriginsOnFileTaskRunner, | 73 base::Bind(&CountOriginsOnFileTaskRunner, |
70 base::RetainedRef(filesystem_context)), | 74 base::RetainedRef(filesystem_context)), |
71 base::Bind(&MediaLicensesCounter::OnContentLicensesObtained, | 75 base::Bind(&MediaLicensesCounter::OnContentLicensesObtained, |
72 weak_ptr_factory_.GetWeakPtr())); | 76 weak_ptr_factory_.GetWeakPtr())); |
73 } | 77 } |
74 | 78 |
75 void MediaLicensesCounter::OnContentLicensesObtained( | 79 void MediaLicensesCounter::OnContentLicensesObtained( |
76 const std::set<GURL>& origins) { | 80 const std::set<GURL>& origins) { |
77 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 81 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
78 ReportResult(base::WrapUnique(new MediaLicenseResult(this, origins))); | 82 ReportResult(base::WrapUnique(new MediaLicenseResult(this, origins))); |
79 } | 83 } |
OLD | NEW |