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

Unified Diff: chrome/browser/search_engines/search_provider_install_state_message_filter.h

Issue 2072613003: Convert GetSearchProviderInstallState to Mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Gyp 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/search_engines/search_provider_install_state_message_filter.h
diff --git a/chrome/browser/search_engines/search_provider_install_state_message_filter.h b/chrome/browser/search_engines/search_provider_install_state_message_filter.h
index 8c7de99087cbbe436348005bafaa5b2a68f7fbc0..ba0663c34f1b3830a544056679da9d8dd9a2fac3 100644
--- a/chrome/browser/search_engines/search_provider_install_state_message_filter.h
+++ b/chrome/browser/search_engines/search_provider_install_state_message_filter.h
@@ -7,41 +7,53 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
+#include "base/supports_user_data.h"
#include "chrome/browser/search_engines/search_provider_install_data.h"
+#include "chrome/common/render.mojom.h"
#include "chrome/common/search_provider.h"
#include "content/public/browser/browser_message_filter.h"
+#include "mojo/public/cpp/bindings/binding_set.h"
+#include "mojo/public/cpp/bindings/callback.h"
class GURL;
class Profile;
+class SearchProviderInstallStateMessageFilterAdapter;
+
// Handles messages regarding search provider install state on the I/O thread.
class SearchProviderInstallStateMessageFilter
Sam McNally 2016/06/20 01:27:11 Rename this to SearchProviderInstallStateImpl and
tibell 2016/06/20 03:19:55 Done.
- : public content::BrowserMessageFilter {
+ : public mojom::SearchProviderInstallState {
public:
// Unlike the other methods, the constructor must be called on the UI thread.
SearchProviderInstallStateMessageFilter(int render_process_id,
Profile* profile);
- // content::BrowserMessageFilter implementation.
- bool OnMessageReceived(const IPC::Message& message) override;
+ void Bind(mojom::SearchProviderInstallStateRequest request);
+
+ // Key used to attach the filter to the RenderProcessHost.
+ static const char kRenderProcessHostKey[];
+
- private:
~SearchProviderInstallStateMessageFilter() override;
+ private:
// Figures out the install state for the search provider.
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);
+ void GetInstallState(
Sam McNally 2016/06/20 01:27:11 // mojom::SearchProviderInstallState override.
tibell 2016/06/20 03:19:55 Done.
+ const GURL& page_location,
+ const GURL& requested_host,
+ const mojo::Callback<void(search_provider::InstallState)>& callback)
Sam McNally 2016/06/20 01:27:11 GetInstallStateCallback. Change everywhere.
tibell 2016/06/20 03:19:55 Done.
+ 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);
+ void ReplyWithProviderInstallState(
+ const GURL& page_location,
+ const GURL& requested_host,
+ const mojo::Callback<void(search_provider::InstallState)>& callback);
// Used to do a load and get information about install states.
SearchProviderInstallData provider_data_;
@@ -50,10 +62,32 @@ class SearchProviderInstallStateMessageFilter
// thread.
const bool is_off_the_record_;
+ // TODO(tibell): Add binding of some sort. Binding on IO thread.
Sam McNally 2016/06/20 01:27:11 Remove?
tibell 2016/06/20 03:19:55 Done.
+ mojo::BindingSet<mojom::SearchProviderInstallState> binding_set_;
+
// Used to schedule invocations of ReplyWithProviderInstallState.
base::WeakPtrFactory<SearchProviderInstallStateMessageFilter> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(SearchProviderInstallStateMessageFilter);
};
+// Adapter used to store the filter inside user data and be deleted on the right
+// thread.
+class SearchProviderInstallStateMessageFilterAdapter
+ : public base::SupportsUserData::Data {
+ public:
+ // Takes ownership of the argument.
+ SearchProviderInstallStateMessageFilterAdapter(
Sam McNally 2016/06/20 01:27:11 explicit.
tibell 2016/06/20 03:19:55 Done.
+ SearchProviderInstallStateMessageFilter* filter);
Sam McNally 2016/06/20 01:27:11 This could take a unique_ptr.
tibell 2016/06/20 03:19:55 Done.
+ ~SearchProviderInstallStateMessageFilterAdapter() override;
+
+ SearchProviderInstallStateMessageFilter* Get() { return ptr_.get(); }
Sam McNally 2016/06/20 01:27:11 get()
tibell 2016/06/20 03:19:55 Done.
+
+ private:
+ std::unique_ptr<SearchProviderInstallStateMessageFilter,
+ content::BrowserThread::DeleteOnIOThread> ptr_;
+
+ DISALLOW_COPY_AND_ASSIGN(SearchProviderInstallStateMessageFilterAdapter);
+};
+
#endif // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_STATE_MESSAGE_FILTER_H_

Powered by Google App Engine
This is Rietveld 408576698