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

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..7f7ec0afd49cd9ac7ea109c09dbde1554c841f1a
--- /dev/null
+++ b/chrome/browser/browsing_data/media_licenses_counter.cc
@@ -0,0 +1,84 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// 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 "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 {
+
+using OriginsDeterminedCB = base::Callback<void(const std::set<GURL>&)>;
+
+// Determining the origins must be run on the file task thread. This calls
+// |callback| on the main thread with the results.
+void CountOriginsOnFileTaskRunner(
+ scoped_refptr<storage::FileSystemContext> filesystem_context,
+ const OriginsDeterminedCB& callback) {
+ 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);
+ content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
+ base::Bind(callback, 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());
+ filesystem_context->default_file_task_runner()->PostTask(
+ FROM_HERE,
+ base::Bind(&CountOriginsOnFileTaskRunner,
+ base::Passed(std::move(filesystem_context)),
michaeln 2016/06/21 20:23:41 This looks a little dicey, is it possible for the
jrummell 2016/06/23 02:48:55 Done.
+ 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