Commit e1c14e51 authored by Evan Stade's avatar Evan Stade

Move StorageInfoFetcher to //components/browser_ui/site_settings

TBR=kinuko@chromium.org

Bug: 1058600
Change-Id: I7eb62790b096cacde13fd0392caa71a7bfc35a7a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2131358Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Reviewed-by: default avatarRobbie McElrath <rmcelrath@chromium.org>
Reviewed-by: default avatarNatalie Chouinard <chouinard@chromium.org>
Reviewed-by: default avatarFinnur Thorarinsson <finnur@chromium.org>
Cr-Commit-Position: refs/heads/master@{#755916}
parent bf7504bf
...@@ -1777,8 +1777,6 @@ jumbo_static_library("browser") { ...@@ -1777,8 +1777,6 @@ jumbo_static_library("browser") {
"status_icons/status_tray.h", "status_icons/status_tray.h",
"storage/durable_storage_permission_context.cc", "storage/durable_storage_permission_context.cc",
"storage/durable_storage_permission_context.h", "storage/durable_storage_permission_context.h",
"storage/storage_info_fetcher.cc",
"storage/storage_info_fetcher.h",
"subresource_filter/chrome_subresource_filter_client.cc", "subresource_filter/chrome_subresource_filter_client.cc",
"subresource_filter/chrome_subresource_filter_client.h", "subresource_filter/chrome_subresource_filter_client.h",
"subresource_filter/subresource_filter_content_settings_manager.cc", "subresource_filter/subresource_filter_content_settings_manager.cc",
......
...@@ -4,6 +4,7 @@ include_rules = [ ...@@ -4,6 +4,7 @@ include_rules = [
"+cc/layers/layer.h", "+cc/layers/layer.h",
"+chrome/android/test_support_jni_headers", "+chrome/android/test_support_jni_headers",
"+chrome_jni_registration/chrome_jni_registration.h", "+chrome_jni_registration/chrome_jni_registration.h",
"+components/browser_ui/site_settings/android",
"+components/browser_ui/util/android/url_constants.h", "+components/browser_ui/util/android/url_constants.h",
"+device/vr/buildflags/buildflags.h", "+device/vr/buildflags/buildflags.h",
"+media/gpu", "+media/gpu",
......
...@@ -25,8 +25,8 @@ ...@@ -25,8 +25,8 @@
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_android.h" #include "chrome/browser/profiles/profile_android.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/storage/storage_info_fetcher.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "components/browser_ui/site_settings/android/storage_info_fetcher.h"
#include "components/browsing_data/content/local_storage_helper.h" #include "components/browsing_data/content/local_storage_helper.h"
#include "components/cdm/browser/media_drm_storage_impl.h" #include "components/cdm/browser/media_drm_storage_impl.h"
#include "components/content_settings/core/browser/cookie_settings.h" #include "components/content_settings/core/browser/cookie_settings.h"
...@@ -756,8 +756,9 @@ static void JNI_WebsitePreferenceBridge_FetchStorageInfo( ...@@ -756,8 +756,9 @@ static void JNI_WebsitePreferenceBridge_FetchStorageInfo(
const JavaParamRef<jobject>& java_callback) { const JavaParamRef<jobject>& java_callback) {
Profile* profile = ProfileManager::GetActiveUserProfile(); Profile* profile = ProfileManager::GetActiveUserProfile();
auto storage_info_fetcher = base::MakeRefCounted<StorageInfoFetcher>(profile); auto storage_info_fetcher =
storage_info_fetcher->FetchStorageInfo(base::Bind( base::MakeRefCounted<browser_ui::StorageInfoFetcher>(profile);
storage_info_fetcher->FetchStorageInfo(base::BindOnce(
&OnStorageInfoReady, ScopedJavaGlobalRef<jobject>(java_callback))); &OnStorageInfoReady, ScopedJavaGlobalRef<jobject>(java_callback)));
} }
...@@ -783,11 +784,12 @@ static void JNI_WebsitePreferenceBridge_ClearStorageData( ...@@ -783,11 +784,12 @@ static void JNI_WebsitePreferenceBridge_ClearStorageData(
Profile* profile = ProfileManager::GetActiveUserProfile(); Profile* profile = ProfileManager::GetActiveUserProfile();
std::string host = ConvertJavaStringToUTF8(env, jhost); std::string host = ConvertJavaStringToUTF8(env, jhost);
auto storage_info_fetcher = base::MakeRefCounted<StorageInfoFetcher>(profile); auto storage_info_fetcher =
base::MakeRefCounted<browser_ui::StorageInfoFetcher>(profile);
storage_info_fetcher->ClearStorage( storage_info_fetcher->ClearStorage(
host, static_cast<blink::mojom::StorageType>(type), host, static_cast<blink::mojom::StorageType>(type),
base::Bind(&OnStorageInfoCleared, base::BindOnce(&OnStorageInfoCleared,
ScopedJavaGlobalRef<jobject>(java_callback))); ScopedJavaGlobalRef<jobject>(java_callback)));
} }
static void JNI_WebsitePreferenceBridge_ClearCookieData( static void JNI_WebsitePreferenceBridge_ClearCookieData(
......
...@@ -2,8 +2,6 @@ jsbell@chromium.org ...@@ -2,8 +2,6 @@ jsbell@chromium.org
kinuko@chromium.org kinuko@chromium.org
pwnall@chromium.org pwnall@chromium.org
per-file storage_info_fetcher.*=finnur@chromium.org
per-file *permission_context*=file://components/permissions/PERMISSIONS_OWNERS per-file *permission_context*=file://components/permissions/PERMISSIONS_OWNERS
# TEAM: storage-dev@chromium.org # TEAM: storage-dev@chromium.org
......
include_rules = [
"+content/public/browser",
"+storage/browser",
"+third_party/blink/public/mojom",
]
...@@ -22,9 +22,13 @@ source_set("android") { ...@@ -22,9 +22,13 @@ source_set("android") {
"features.cc", "features.cc",
"features.h", "features.h",
"site_settings_feature_list.cc", "site_settings_feature_list.cc",
"storage_info_fetcher.cc",
"storage_info_fetcher.h",
] ]
deps = [ deps = [
":site_settings_jni_headers", ":site_settings_jni_headers",
"//base", "//base",
"//content/public/browser",
"//storage/browser",
] ]
} }
...@@ -2,11 +2,10 @@ ...@@ -2,11 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/storage/storage_info_fetcher.h" #include "components/browser_ui/site_settings/android/storage_info_fetcher.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
...@@ -16,18 +15,20 @@ ...@@ -16,18 +15,20 @@
using content::BrowserContext; using content::BrowserContext;
using content::BrowserThread; using content::BrowserThread;
StorageInfoFetcher::StorageInfoFetcher(Profile* profile) { namespace browser_ui {
quota_manager_ = content::BrowserContext::GetDefaultStoragePartition(
profile)->GetQuotaManager(); StorageInfoFetcher::StorageInfoFetcher(content::BrowserContext* context) {
quota_manager_ = content::BrowserContext::GetDefaultStoragePartition(context)
->GetQuotaManager();
} }
StorageInfoFetcher::~StorageInfoFetcher() = default; StorageInfoFetcher::~StorageInfoFetcher() = default;
void StorageInfoFetcher::FetchStorageInfo(const FetchCallback& fetch_callback) { void StorageInfoFetcher::FetchStorageInfo(FetchCallback fetch_callback) {
// Balanced in OnFetchCompleted. // Balanced in OnFetchCompleted.
AddRef(); AddRef();
fetch_callback_ = fetch_callback; fetch_callback_ = std::move(fetch_callback);
// QuotaManager must be called on IO thread, but the callback must then be // QuotaManager must be called on IO thread, but the callback must then be
// called on the UI thread. // called on the UI thread.
...@@ -40,11 +41,11 @@ void StorageInfoFetcher::FetchStorageInfo(const FetchCallback& fetch_callback) { ...@@ -40,11 +41,11 @@ void StorageInfoFetcher::FetchStorageInfo(const FetchCallback& fetch_callback) {
void StorageInfoFetcher::ClearStorage(const std::string& host, void StorageInfoFetcher::ClearStorage(const std::string& host,
blink::mojom::StorageType type, blink::mojom::StorageType type,
const ClearCallback& clear_callback) { ClearCallback clear_callback) {
// Balanced in OnUsageCleared. // Balanced in OnUsageCleared.
AddRef(); AddRef();
clear_callback_ = clear_callback; clear_callback_ = std::move(clear_callback);
type_to_delete_ = type; type_to_delete_ = type;
base::PostTask( base::PostTask(
...@@ -73,7 +74,7 @@ void StorageInfoFetcher::OnGetUsageInfoInternal( ...@@ -73,7 +74,7 @@ void StorageInfoFetcher::OnGetUsageInfoInternal(
void StorageInfoFetcher::OnFetchCompleted() { void StorageInfoFetcher::OnFetchCompleted() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
fetch_callback_.Run(entries_); std::move(fetch_callback_).Run(entries_);
Release(); Release();
} }
...@@ -92,7 +93,9 @@ void StorageInfoFetcher::OnUsageClearedInternal( ...@@ -92,7 +93,9 @@ void StorageInfoFetcher::OnUsageClearedInternal(
void StorageInfoFetcher::OnClearCompleted(blink::mojom::QuotaStatusCode code) { void StorageInfoFetcher::OnClearCompleted(blink::mojom::QuotaStatusCode code) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
clear_callback_.Run(code); std::move(clear_callback_).Run(code);
Release(); Release();
} }
} // namespace browser_ui
...@@ -2,37 +2,41 @@ ...@@ -2,37 +2,41 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_STORAGE_STORAGE_INFO_FETCHER_H_ #ifndef COMPONENTS_BROWSER_UI_SITE_SETTINGS_ANDROID_STORAGE_INFO_FETCHER_H_
#define CHROME_BROWSER_STORAGE_STORAGE_INFO_FETCHER_H_ #define COMPONENTS_BROWSER_UI_SITE_SETTINGS_ANDROID_STORAGE_INFO_FETCHER_H_
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "storage/browser/quota/quota_callbacks.h" #include "storage/browser/quota/quota_callbacks.h"
#include "third_party/blink/public/mojom/quota/quota_types.mojom-forward.h" #include "third_party/blink/public/mojom/quota/quota_types.mojom-forward.h"
namespace content {
class BrowserContext;
}
namespace storage { namespace storage {
class QuotaManager; class QuotaManager;
} }
class Profile; namespace browser_ui {
// Asynchronously fetches the amount of storage used by websites. // Asynchronously fetches the amount of storage used by websites.
class StorageInfoFetcher : class StorageInfoFetcher
public base::RefCountedThreadSafe<StorageInfoFetcher> { : public base::RefCountedThreadSafe<StorageInfoFetcher> {
public: public:
using FetchCallback = using FetchCallback =
base::Callback<void(const storage::UsageInfoEntries&)>; base::OnceCallback<void(const storage::UsageInfoEntries&)>;
using ClearCallback = using ClearCallback =
base::Callback<void(blink::mojom::QuotaStatusCode code)>; base::OnceCallback<void(blink::mojom::QuotaStatusCode code)>;
explicit StorageInfoFetcher(Profile* profile); explicit StorageInfoFetcher(content::BrowserContext* context);
// Asynchronously fetches the StorageInfo. // Asynchronously fetches the StorageInfo.
void FetchStorageInfo(const FetchCallback& fetch_callback); void FetchStorageInfo(FetchCallback fetch_callback);
// Asynchronously clears storage for the given host. // Asynchronously clears storage for the given host.
void ClearStorage(const std::string& host, void ClearStorage(const std::string& host,
blink::mojom::StorageType type, blink::mojom::StorageType type,
const ClearCallback& clear_callback); ClearCallback clear_callback);
private: private:
virtual ~StorageInfoFetcher(); virtual ~StorageInfoFetcher();
...@@ -72,4 +76,6 @@ class StorageInfoFetcher : ...@@ -72,4 +76,6 @@ class StorageInfoFetcher :
DISALLOW_COPY_AND_ASSIGN(StorageInfoFetcher); DISALLOW_COPY_AND_ASSIGN(StorageInfoFetcher);
}; };
#endif // CHROME_BROWSER_STORAGE_STORAGE_INFO_FETCHER_H_ } // namespace browser_ui
#endif // COMPONENTS_BROWSER_UI_SITE_SETTINGS_ANDROID_STORAGE_INFO_FETCHER_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment