Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1298)

Side by Side Diff: chrome/browser/browsing_data/media_licenses_counter.cc

Issue 2084903002: Moved BrowsingDataCounter and part of BrowsingDataCounterUtils to components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/common/pref_names.h" 13 #include "chrome/common/pref_names.h"
13 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/storage_partition.h" 15 #include "content/public/browser/storage_partition.h"
15 #include "storage/browser/fileapi/file_system_context.h" 16 #include "storage/browser/fileapi/file_system_context.h"
16 17
17 namespace { 18 namespace {
18 19
19 // Determining the origins must be run on the file task thread. 20 // Determining the origins must be run on the file task thread.
20 std::set<GURL> CountOriginsOnFileTaskRunner( 21 std::set<GURL> CountOriginsOnFileTaskRunner(
21 storage::FileSystemContext* filesystem_context) { 22 storage::FileSystemContext* filesystem_context) {
(...skipping 21 matching lines...) Expand all
43 one_origin_ = origins.begin()->GetOrigin().host(); 44 one_origin_ = origins.begin()->GetOrigin().host();
44 } 45 }
45 46
46 MediaLicensesCounter::MediaLicenseResult::~MediaLicenseResult() {} 47 MediaLicensesCounter::MediaLicenseResult::~MediaLicenseResult() {}
47 48
48 const std::string& MediaLicensesCounter::MediaLicenseResult::GetOneOrigin() 49 const std::string& MediaLicensesCounter::MediaLicenseResult::GetOneOrigin()
49 const { 50 const {
50 return one_origin_; 51 return one_origin_;
51 } 52 }
52 53
53 MediaLicensesCounter::MediaLicensesCounter() 54 MediaLicensesCounter::MediaLicensesCounter(Profile* profile)
54 : pref_name_(prefs::kDeleteMediaLicenses), weak_ptr_factory_(this) {} 55 : BrowsingDataCounter(prefs::kDeleteMediaLicenses),
56 profile_(profile),
57 weak_ptr_factory_(this) {}
55 58
56 MediaLicensesCounter::~MediaLicensesCounter() {} 59 MediaLicensesCounter::~MediaLicensesCounter() {}
57 60
58 const std::string& MediaLicensesCounter::GetPrefName() const {
59 return pref_name_;
60 }
61
62 void MediaLicensesCounter::Count() { 61 void MediaLicensesCounter::Count() {
63 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 62 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
64 scoped_refptr<storage::FileSystemContext> filesystem_context = 63 scoped_refptr<storage::FileSystemContext> filesystem_context =
65 make_scoped_refptr( 64 make_scoped_refptr(
66 content::BrowserContext::GetDefaultStoragePartition(GetProfile()) 65 content::BrowserContext::GetDefaultStoragePartition(profile_)
67 ->GetFileSystemContext()); 66 ->GetFileSystemContext());
68 base::PostTaskAndReplyWithResult( 67 base::PostTaskAndReplyWithResult(
69 filesystem_context->default_file_task_runner(), FROM_HERE, 68 filesystem_context->default_file_task_runner(), FROM_HERE,
70 base::Bind(&CountOriginsOnFileTaskRunner, 69 base::Bind(&CountOriginsOnFileTaskRunner,
71 base::RetainedRef(filesystem_context)), 70 base::RetainedRef(filesystem_context)),
72 base::Bind(&MediaLicensesCounter::OnContentLicensesObtained, 71 base::Bind(&MediaLicensesCounter::OnContentLicensesObtained,
73 weak_ptr_factory_.GetWeakPtr())); 72 weak_ptr_factory_.GetWeakPtr()));
74 } 73 }
75 74
76 void MediaLicensesCounter::OnContentLicensesObtained( 75 void MediaLicensesCounter::OnContentLicensesObtained(
77 const std::set<GURL>& origins) { 76 const std::set<GURL>& origins) {
78 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 77 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
79 ReportResult(base::WrapUnique(new MediaLicenseResult(this, origins))); 78 ReportResult(base::WrapUnique(new MediaLicenseResult(this, origins)));
80 } 79 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698