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

Unified 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: changes Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/browsing_data/media_licenses_counter.cc
diff --git a/chrome/browser/browsing_data/media_licenses_counter.cc b/chrome/browser/browsing_data/media_licenses_counter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..be92263f80985f4bc38e0a69b1515ba35fb9763e
--- /dev/null
+++ b/chrome/browser/browsing_data/media_licenses_counter.cc
@@ -0,0 +1,80 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
msramek 2016/06/27 14:27:33 Nit: We don't use (c) anymore (also in the .h file
jrummell 2016/06/28 01:16:48 Done. Just cut&paste from a different file, change
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/browsing_data/media_licenses_counter.h"
+
+#include <stdint.h>
+
+#include "base/memory/ptr_util.h"
+#include "base/memory/ref_counted.h"
+#include "base/task_runner_util.h"
+#include "chrome/common/pref_names.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/storage_partition.h"
+#include "storage/browser/fileapi/file_system_context.h"
+
+namespace {
+
+// Determining the origins must be run on the file task thread.
+std::set<GURL> CountOriginsOnFileTaskRunner(
+ storage::FileSystemContext* filesystem_context) {
+ DCHECK(filesystem_context->default_file_task_runner()
+ ->RunsTasksOnCurrentThread());
+
+ storage::FileSystemBackend* backend =
+ filesystem_context->GetFileSystemBackend(
+ storage::kFileSystemTypePluginPrivate);
+ storage::FileSystemQuotaUtil* quota_util = backend->GetQuotaUtil();
+
+ std::set<GURL> origins;
+ quota_util->GetOriginsForTypeOnFileTaskRunner(
+ storage::kFileSystemTypePluginPrivate, &origins);
+ return origins;
+}
+
+} // namespace
+
+MediaLicenseCounter::MediaLicenseResult::MediaLicenseResult(
+ const MediaLicenseCounter* source,
+ const std::set<GURL>& origins)
+ : FinishedResult(source, origins.size()) {
+ if (!origins.empty())
+ one_origin_ = origins.begin()->GetOrigin().spec();
+}
+
+MediaLicenseCounter::MediaLicenseResult::~MediaLicenseResult() {}
+
+const std::string& MediaLicenseCounter::MediaLicenseResult::GetOneOrigin()
+ const {
+ return one_origin_;
+}
+
+MediaLicenseCounter::MediaLicenseCounter()
+ : pref_name_(prefs::kDeleteMediaLicenses), weak_ptr_factory_(this) {}
+
+MediaLicenseCounter::~MediaLicenseCounter() {}
+
+const std::string& MediaLicenseCounter::GetPrefName() const {
+ return pref_name_;
+}
+
+void MediaLicenseCounter::Count() {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ scoped_refptr<storage::FileSystemContext> filesystem_context =
+ make_scoped_refptr(
+ content::BrowserContext::GetDefaultStoragePartition(GetProfile())
+ ->GetFileSystemContext());
+ base::PostTaskAndReplyWithResult(
+ filesystem_context->default_file_task_runner(), FROM_HERE,
+ base::Bind(&CountOriginsOnFileTaskRunner,
+ base::RetainedRef(filesystem_context)),
+ base::Bind(&MediaLicenseCounter::OnContentLicensesObtained,
+ weak_ptr_factory_.GetWeakPtr()));
+}
+
+void MediaLicenseCounter::OnContentLicensesObtained(
+ const std::set<GURL>& origins) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ ReportResult(base::WrapUnique(new MediaLicenseResult(this, origins)));
+}

Powered by Google App Engine
This is Rietveld 408576698