Commit 105efb82 authored by Matt Falkenhagen's avatar Matt Falkenhagen Committed by Commit Bot

Content Index: Prepare for service worker UI thread core.

The thread ServiceWorkerContextCore lives on (the "core thread") will
move from the IO thread to the UI thread when the ServiceWorkerOnUI
feature is enabled.

This CL makes Content Index aware of the core thread instead of assuming
the IO thread. This makes ContentIndex* browser_tests pass when the
feature is enabled.

Bug: 824858
Change-Id: I03e81a564b27ee888a3402fdff11d8b51f3489a5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1775882Reviewed-by: default avatarRayan Kanso <rayankans@chromium.org>
Commit-Queue: Matt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#691787}
parent 82f105ae
...@@ -80,28 +80,30 @@ class CONTENT_EXPORT ContentIndexDatabase { ...@@ -80,28 +80,30 @@ class CONTENT_EXPORT ContentIndexDatabase {
BlockedOriginsCannotRegisterContent); BlockedOriginsCannotRegisterContent);
FRIEND_TEST_ALL_PREFIXES(ContentIndexDatabaseTest, UmaRecorded); FRIEND_TEST_ALL_PREFIXES(ContentIndexDatabaseTest, UmaRecorded);
// public method IO counterparts. // public method service worker core thread counterparts.
void AddEntryOnIO(int64_t service_worker_registration_id, void AddEntryOnCoreThread(
const url::Origin& origin, int64_t service_worker_registration_id,
blink::mojom::ContentDescriptionPtr description, const url::Origin& origin,
const std::vector<SkBitmap>& icons, blink::mojom::ContentDescriptionPtr description,
const GURL& launch_url, const std::vector<SkBitmap>& icons,
blink::mojom::ContentIndexService::AddCallback callback); const GURL& launch_url,
void DeleteEntryOnIO( blink::mojom::ContentIndexService::AddCallback callback);
void DeleteEntryOnCoreThread(
int64_t service_worker_registration_id, int64_t service_worker_registration_id,
const url::Origin& origin, const url::Origin& origin,
const std::string& entry_id, const std::string& entry_id,
blink::mojom::ContentIndexService::DeleteCallback callback); blink::mojom::ContentIndexService::DeleteCallback callback);
void GetDescriptionsOnIO( void GetDescriptionsOnCoreThread(
int64_t service_worker_registration_id, int64_t service_worker_registration_id,
blink::mojom::ContentIndexService::GetDescriptionsCallback callback); blink::mojom::ContentIndexService::GetDescriptionsCallback callback);
void GetIconsOnIO(int64_t service_worker_registration_id, void GetIconsOnCoreThread(int64_t service_worker_registration_id,
const std::string& description_id, const std::string& description_id,
ContentIndexContext::GetIconsCallback callback); ContentIndexContext::GetIconsCallback callback);
void GetAllEntriesOnIO(ContentIndexContext::GetAllEntriesCallback callback); void GetAllEntriesOnCoreThread(
void GetEntryOnIO(int64_t service_worker_registration_id, ContentIndexContext::GetAllEntriesCallback callback);
const std::string& description_id, void GetEntryOnCoreThread(int64_t service_worker_registration_id,
ContentIndexContext::GetEntryCallback callback); const std::string& description_id,
ContentIndexContext::GetEntryCallback callback);
// Add Callbacks. // Add Callbacks.
void DidSerializeIcons( void DidSerializeIcons(
...@@ -179,11 +181,11 @@ class CONTENT_EXPORT ContentIndexDatabase { ...@@ -179,11 +181,11 @@ class CONTENT_EXPORT ContentIndexDatabase {
ContentIndexProvider* provider_; ContentIndexProvider* provider_;
// A map from origins to how many times it's been blocked. // A map from origins to how many times it's been blocked.
// Must be used on the IO thread. // Must be used on the service worker core thread.
base::flat_map<url::Origin, int> blocked_origins_; base::flat_map<url::Origin, int> blocked_origins_;
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
base::WeakPtrFactory<ContentIndexDatabase> weak_ptr_factory_io_{this}; base::WeakPtrFactory<ContentIndexDatabase> weak_ptr_factory_core_{this};
base::WeakPtrFactory<ContentIndexDatabase> weak_ptr_factory_ui_{this}; base::WeakPtrFactory<ContentIndexDatabase> weak_ptr_factory_ui_{this};
DISALLOW_COPY_AND_ASSIGN(ContentIndexDatabase); DISALLOW_COPY_AND_ASSIGN(ContentIndexDatabase);
......
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