Chromium Code Reviews| Index: chrome/browser/search_engines/search_provider_install_state_impl.h |
| diff --git a/chrome/browser/search_engines/search_provider_install_state_message_filter.h b/chrome/browser/search_engines/search_provider_install_state_impl.h |
| similarity index 41% |
| rename from chrome/browser/search_engines/search_provider_install_state_message_filter.h |
| rename to chrome/browser/search_engines/search_provider_install_state_impl.h |
| index 8c7de99087cbbe436348005bafaa5b2a68f7fbc0..12cfb5a6b3c8f6fa0a289ee0dadca2bca1f10655 100644 |
| --- a/chrome/browser/search_engines/search_provider_install_state_message_filter.h |
| +++ b/chrome/browser/search_engines/search_provider_install_state_impl.h |
| @@ -2,46 +2,57 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_STATE_MESSAGE_FILTER_H_ |
| -#define CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_STATE_MESSAGE_FILTER_H_ |
| +#ifndef CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_STATE_IMPL_H_ |
| +#define CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_STATE_IMPL_H_ |
| +#include "base/callback.h" |
| #include "base/macros.h" |
| #include "base/memory/weak_ptr.h" |
| +#include "base/supports_user_data.h" |
| +#include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/search_engines/search_provider_install_data.h" |
| #include "chrome/common/search_provider.h" |
| +#include "chrome/common/search_provider.mojom.h" |
| #include "content/public/browser/browser_message_filter.h" |
| +#include "content/public/browser/render_process_host.h" |
| +#include "content/public/common/service_registry.h" |
| +#include "mojo/public/cpp/bindings/binding_set.h" |
| class GURL; |
| class Profile; |
| +class SearchProviderInstallStateImplAdapter; |
| + |
| // Handles messages regarding search provider install state on the I/O thread. |
| -class SearchProviderInstallStateMessageFilter |
| - : public content::BrowserMessageFilter { |
| +class SearchProviderInstallStateImpl |
| + : public mojom::SearchProviderInstallState { |
| public: |
| // Unlike the other methods, the constructor must be called on the UI thread. |
| - SearchProviderInstallStateMessageFilter(int render_process_id, |
| - Profile* profile); |
| + SearchProviderInstallStateImpl(int render_process_id, Profile* profile); |
| - // content::BrowserMessageFilter implementation. |
| - bool OnMessageReceived(const IPC::Message& message) override; |
| + // Create impl and register it in the host's service registry. |
| + static void InstallService(content::RenderProcessHost* host); |
| - private: |
| - ~SearchProviderInstallStateMessageFilter() override; |
| + void Bind(mojom::SearchProviderInstallStateRequest request); |
| + ~SearchProviderInstallStateImpl() override; |
|
sky
2016/06/20 15:20:26
nit: move beneath constructor (see style guide).
tibell
2016/06/21 01:31:32
Done.
|
| + |
| + private: |
| // Figures out the install state for the search provider. |
| - search_provider::InstallState GetSearchProviderInstallState( |
| + search_provider::InstallState GetSearchProviderInstallState( |
| const GURL& page_location, |
| const GURL& requested_host); |
| // Starts handling the message requesting the search provider install state. |
| - void OnGetSearchProviderInstallState(const GURL& page_location, |
| - const GURL& requested_host, |
| - IPC::Message* reply_msg); |
| + // mojom::SearchProviderInstallState override. |
| + void GetInstallState(const GURL& page_location, |
| + const GURL& requested_host, |
| + const GetInstallStateCallback& callback) override; |
| // Sends the reply message about the search provider install state. |
| void ReplyWithProviderInstallState(const GURL& page_location, |
| const GURL& requested_host, |
| - IPC::Message* reply_msg); |
| + const GetInstallStateCallback& callback); |
| // Used to do a load and get information about install states. |
| SearchProviderInstallData provider_data_; |
| @@ -50,10 +61,35 @@ class SearchProviderInstallStateMessageFilter |
| // thread. |
| const bool is_off_the_record_; |
| + mojo::BindingSet<mojom::SearchProviderInstallState> binding_set_; |
| + |
| + // Key used to attach the filter to the RenderProcessHost. |
| + static const char kRenderProcessHostKey[]; |
|
sky
2016/06/20 15:20:26
should be first (see style guide).
tibell
2016/06/21 01:31:32
Done.
Made it an implementation detail of the .cc
|
| + |
| // Used to schedule invocations of ReplyWithProviderInstallState. |
| - base::WeakPtrFactory<SearchProviderInstallStateMessageFilter> weak_factory_; |
| + base::WeakPtrFactory<SearchProviderInstallStateImpl> weak_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(SearchProviderInstallStateImpl); |
| +}; |
| + |
| +// Adapter used to store the impl in user data and to make sure it's deleted on |
| +// the right thread. |
| +class SearchProviderInstallStateImplAdapter |
|
Sam McNally
2016/06/20 08:05:18
Can this move into the .cc file?
tibell
2016/06/21 01:31:32
Done.
It can be now after I moved the constructio
|
| + : public base::SupportsUserData::Data { |
| + public: |
| + explicit SearchProviderInstallStateImplAdapter( |
| + std::unique_ptr<SearchProviderInstallStateImpl, |
| + content::BrowserThread::DeleteOnIOThread> filter); |
| + ~SearchProviderInstallStateImplAdapter() override; |
| + |
| + SearchProviderInstallStateImpl* get() { return ptr_.get(); } |
| + |
| + private: |
| + std::unique_ptr<SearchProviderInstallStateImpl, |
| + content::BrowserThread::DeleteOnIOThread> |
| + ptr_; |
| - DISALLOW_COPY_AND_ASSIGN(SearchProviderInstallStateMessageFilter); |
| + DISALLOW_COPY_AND_ASSIGN(SearchProviderInstallStateImplAdapter); |
| }; |
| -#endif // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_STATE_MESSAGE_FILTER_H_ |
| +#endif // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_STATE_IMPL_H_ |