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

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

Issue 2075023002: UI Changes to support clearing EME/CDM data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revert options_page.css 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/browsing_data/media_licenses_counter.h"
6
7 #include <stdint.h>
8
9 #include "base/memory/ptr_util.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/task_runner_util.h"
12 #include "chrome/common/pref_names.h"
13 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/storage_partition.h"
15 #include "storage/browser/fileapi/file_system_context.h"
16
17 namespace {
18
19 // Determining the origins must be run on the file task thread.
20 std::set<GURL> CountOriginsOnFileTaskRunner(
21 storage::FileSystemContext* filesystem_context) {
22 DCHECK(filesystem_context->default_file_task_runner()
23 ->RunsTasksOnCurrentThread());
24
25 storage::FileSystemBackend* backend =
26 filesystem_context->GetFileSystemBackend(
27 storage::kFileSystemTypePluginPrivate);
28 storage::FileSystemQuotaUtil* quota_util = backend->GetQuotaUtil();
29
30 std::set<GURL> origins;
31 quota_util->GetOriginsForTypeOnFileTaskRunner(
32 storage::kFileSystemTypePluginPrivate, &origins);
33 return origins;
34 }
35
36 } // namespace
37
38 MediaLicensesCounter::MediaLicenseResult::MediaLicenseResult(
39 const MediaLicensesCounter* source,
40 const std::set<GURL>& origins)
41 : FinishedResult(source, origins.size()) {
42 if (!origins.empty())
43 one_origin_ = origins.begin()->GetOrigin().host();
44 }
45
46 MediaLicensesCounter::MediaLicenseResult::~MediaLicenseResult() {}
47
48 const std::string& MediaLicensesCounter::MediaLicenseResult::GetOneOrigin()
49 const {
50 return one_origin_;
51 }
52
53 MediaLicensesCounter::MediaLicensesCounter()
54 : pref_name_(prefs::kDeleteMediaLicenses), weak_ptr_factory_(this) {}
55
56 MediaLicensesCounter::~MediaLicensesCounter() {}
57
58 const std::string& MediaLicensesCounter::GetPrefName() const {
59 return pref_name_;
60 }
61
62 void MediaLicensesCounter::Count() {
63 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
64 scoped_refptr<storage::FileSystemContext> filesystem_context =
65 make_scoped_refptr(
66 content::BrowserContext::GetDefaultStoragePartition(GetProfile())
67 ->GetFileSystemContext());
68 base::PostTaskAndReplyWithResult(
69 filesystem_context->default_file_task_runner(), FROM_HERE,
70 base::Bind(&CountOriginsOnFileTaskRunner,
71 base::RetainedRef(filesystem_context)),
72 base::Bind(&MediaLicensesCounter::OnContentLicensesObtained,
73 weak_ptr_factory_.GetWeakPtr()));
74 }
75
76 void MediaLicensesCounter::OnContentLicensesObtained(
77 const std::set<GURL>& origins) {
78 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
79 ReportResult(base::WrapUnique(new MediaLicenseResult(this, origins)));
80 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698