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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_STATE_MESSAGE_FILT ER_H_ 5 #ifndef CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_STATE_MESSAGE_FILT ER_H_
6 #define CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_STATE_MESSAGE_FILT ER_H_ 6 #define CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_STATE_MESSAGE_FILT ER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/supports_user_data.h"
10 #include "chrome/browser/search_engines/search_provider_install_data.h" 11 #include "chrome/browser/search_engines/search_provider_install_data.h"
12 #include "chrome/common/render.mojom.h"
11 #include "chrome/common/search_provider.h" 13 #include "chrome/common/search_provider.h"
12 #include "content/public/browser/browser_message_filter.h" 14 #include "content/public/browser/browser_message_filter.h"
15 #include "mojo/public/cpp/bindings/binding_set.h"
16 #include "mojo/public/cpp/bindings/callback.h"
13 17
14 class GURL; 18 class GURL;
15 class Profile; 19 class Profile;
16 20
21 class SearchProviderInstallStateMessageFilterAdapter;
22
17 // Handles messages regarding search provider install state on the I/O thread. 23 // Handles messages regarding search provider install state on the I/O thread.
18 class SearchProviderInstallStateMessageFilter 24 class SearchProviderInstallStateMessageFilter
Sam McNally 2016/06/20 01:27:11 Rename this to SearchProviderInstallStateImpl and
tibell 2016/06/20 03:19:55 Done.
19 : public content::BrowserMessageFilter { 25 : public mojom::SearchProviderInstallState {
20 public: 26 public:
21 // Unlike the other methods, the constructor must be called on the UI thread. 27 // Unlike the other methods, the constructor must be called on the UI thread.
22 SearchProviderInstallStateMessageFilter(int render_process_id, 28 SearchProviderInstallStateMessageFilter(int render_process_id,
23 Profile* profile); 29 Profile* profile);
24 30
25 // content::BrowserMessageFilter implementation. 31 void Bind(mojom::SearchProviderInstallStateRequest request);
26 bool OnMessageReceived(const IPC::Message& message) override; 32
33 // Key used to attach the filter to the RenderProcessHost.
34 static const char kRenderProcessHostKey[];
35
36
37 ~SearchProviderInstallStateMessageFilter() override;
27 38
28 private: 39 private:
29 ~SearchProviderInstallStateMessageFilter() override;
30
31 // Figures out the install state for the search provider. 40 // Figures out the install state for the search provider.
32 search_provider::InstallState GetSearchProviderInstallState( 41 search_provider::InstallState GetSearchProviderInstallState(
33 const GURL& page_location, 42 const GURL& page_location,
34 const GURL& requested_host); 43 const GURL& requested_host);
35 44
36 // Starts handling the message requesting the search provider install state. 45 // Starts handling the message requesting the search provider install state.
37 void OnGetSearchProviderInstallState(const GURL& page_location, 46 void GetInstallState(
Sam McNally 2016/06/20 01:27:11 // mojom::SearchProviderInstallState override.
tibell 2016/06/20 03:19:55 Done.
38 const GURL& requested_host, 47 const GURL& page_location,
39 IPC::Message* reply_msg); 48 const GURL& requested_host,
49 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.
50 override;
40 51
41 // Sends the reply message about the search provider install state. 52 // Sends the reply message about the search provider install state.
42 void ReplyWithProviderInstallState(const GURL& page_location, 53 void ReplyWithProviderInstallState(
43 const GURL& requested_host, 54 const GURL& page_location,
44 IPC::Message* reply_msg); 55 const GURL& requested_host,
56 const mojo::Callback<void(search_provider::InstallState)>& callback);
45 57
46 // Used to do a load and get information about install states. 58 // Used to do a load and get information about install states.
47 SearchProviderInstallData provider_data_; 59 SearchProviderInstallData provider_data_;
48 60
49 // Copied from the profile since the profile can't be accessed on the I/O 61 // Copied from the profile since the profile can't be accessed on the I/O
50 // thread. 62 // thread.
51 const bool is_off_the_record_; 63 const bool is_off_the_record_;
52 64
65 // 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.
66 mojo::BindingSet<mojom::SearchProviderInstallState> binding_set_;
67
53 // Used to schedule invocations of ReplyWithProviderInstallState. 68 // Used to schedule invocations of ReplyWithProviderInstallState.
54 base::WeakPtrFactory<SearchProviderInstallStateMessageFilter> weak_factory_; 69 base::WeakPtrFactory<SearchProviderInstallStateMessageFilter> weak_factory_;
55 70
56 DISALLOW_COPY_AND_ASSIGN(SearchProviderInstallStateMessageFilter); 71 DISALLOW_COPY_AND_ASSIGN(SearchProviderInstallStateMessageFilter);
57 }; 72 };
58 73
74 // Adapter used to store the filter inside user data and be deleted on the right
75 // thread.
76 class SearchProviderInstallStateMessageFilterAdapter
77 : public base::SupportsUserData::Data {
78 public:
79 // Takes ownership of the argument.
80 SearchProviderInstallStateMessageFilterAdapter(
Sam McNally 2016/06/20 01:27:11 explicit.
tibell 2016/06/20 03:19:55 Done.
81 SearchProviderInstallStateMessageFilter* filter);
Sam McNally 2016/06/20 01:27:11 This could take a unique_ptr.
tibell 2016/06/20 03:19:55 Done.
82 ~SearchProviderInstallStateMessageFilterAdapter() override;
83
84 SearchProviderInstallStateMessageFilter* Get() { return ptr_.get(); }
Sam McNally 2016/06/20 01:27:11 get()
tibell 2016/06/20 03:19:55 Done.
85
86 private:
87 std::unique_ptr<SearchProviderInstallStateMessageFilter,
88 content::BrowserThread::DeleteOnIOThread> ptr_;
89
90 DISALLOW_COPY_AND_ASSIGN(SearchProviderInstallStateMessageFilterAdapter);
91 };
92
59 #endif // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_STATE_MESSAGE_F ILTER_H_ 93 #endif // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_STATE_MESSAGE_F ILTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698