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

Side by Side Diff: chrome/browser/search_engines/search_provider_install_state_impl.h

Issue 2072613003: Convert GetSearchProviderInstallState to Mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Small twiddles 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_IMPL_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_IMPL_H_
7 7
8 #include "base/callback.h"
8 #include "base/macros.h" 9 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/supports_user_data.h"
12 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/search_engines/search_provider_install_data.h" 13 #include "chrome/browser/search_engines/search_provider_install_data.h"
11 #include "chrome/common/search_provider.h" 14 #include "chrome/common/search_provider.h"
15 #include "chrome/common/search_provider.mojom.h"
12 #include "content/public/browser/browser_message_filter.h" 16 #include "content/public/browser/browser_message_filter.h"
17 #include "content/public/browser/render_process_host.h"
18 #include "content/public/common/service_registry.h"
19 #include "mojo/public/cpp/bindings/binding_set.h"
13 20
14 class GURL; 21 class GURL;
15 class Profile; 22 class Profile;
16 23
24 class SearchProviderInstallStateImplAdapter;
25
17 // Handles messages regarding search provider install state on the I/O thread. 26 // Handles messages regarding search provider install state on the I/O thread.
18 class SearchProviderInstallStateMessageFilter 27 class SearchProviderInstallStateImpl
19 : public content::BrowserMessageFilter { 28 : public mojom::SearchProviderInstallState {
20 public: 29 public:
21 // Unlike the other methods, the constructor must be called on the UI thread. 30 // Unlike the other methods, the constructor must be called on the UI thread.
22 SearchProviderInstallStateMessageFilter(int render_process_id, 31 SearchProviderInstallStateImpl(int render_process_id, Profile* profile);
23 Profile* profile);
24 32
25 // content::BrowserMessageFilter implementation. 33 // Create impl and register it in the host's service registry.
26 bool OnMessageReceived(const IPC::Message& message) override; 34 static void InstallService(content::RenderProcessHost* host);
35
36 void Bind(mojom::SearchProviderInstallStateRequest request);
37
38 ~SearchProviderInstallStateImpl() override;
sky 2016/06/20 15:20:26 nit: move beneath constructor (see style guide).
tibell 2016/06/21 01:31:32 Done.
27 39
28 private: 40 private:
29 ~SearchProviderInstallStateMessageFilter() override;
30
31 // Figures out the install state for the search provider. 41 // Figures out the install state for the search provider.
32 search_provider::InstallState GetSearchProviderInstallState( 42 search_provider::InstallState GetSearchProviderInstallState(
33 const GURL& page_location, 43 const GURL& page_location,
34 const GURL& requested_host); 44 const GURL& requested_host);
35 45
36 // Starts handling the message requesting the search provider install state. 46 // Starts handling the message requesting the search provider install state.
37 void OnGetSearchProviderInstallState(const GURL& page_location, 47 // mojom::SearchProviderInstallState override.
38 const GURL& requested_host, 48 void GetInstallState(const GURL& page_location,
39 IPC::Message* reply_msg); 49 const GURL& requested_host,
50 const GetInstallStateCallback& callback) 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(const GURL& page_location,
43 const GURL& requested_host, 54 const GURL& requested_host,
44 IPC::Message* reply_msg); 55 const GetInstallStateCallback& callback);
45 56
46 // Used to do a load and get information about install states. 57 // Used to do a load and get information about install states.
47 SearchProviderInstallData provider_data_; 58 SearchProviderInstallData provider_data_;
48 59
49 // Copied from the profile since the profile can't be accessed on the I/O 60 // Copied from the profile since the profile can't be accessed on the I/O
50 // thread. 61 // thread.
51 const bool is_off_the_record_; 62 const bool is_off_the_record_;
52 63
64 mojo::BindingSet<mojom::SearchProviderInstallState> binding_set_;
65
66 // Key used to attach the filter to the RenderProcessHost.
67 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
68
53 // Used to schedule invocations of ReplyWithProviderInstallState. 69 // Used to schedule invocations of ReplyWithProviderInstallState.
54 base::WeakPtrFactory<SearchProviderInstallStateMessageFilter> weak_factory_; 70 base::WeakPtrFactory<SearchProviderInstallStateImpl> weak_factory_;
55 71
56 DISALLOW_COPY_AND_ASSIGN(SearchProviderInstallStateMessageFilter); 72 DISALLOW_COPY_AND_ASSIGN(SearchProviderInstallStateImpl);
57 }; 73 };
58 74
59 #endif // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_STATE_MESSAGE_F ILTER_H_ 75 // Adapter used to store the impl in user data and to make sure it's deleted on
76 // the right thread.
77 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
78 : public base::SupportsUserData::Data {
79 public:
80 explicit SearchProviderInstallStateImplAdapter(
81 std::unique_ptr<SearchProviderInstallStateImpl,
82 content::BrowserThread::DeleteOnIOThread> filter);
83 ~SearchProviderInstallStateImplAdapter() override;
84
85 SearchProviderInstallStateImpl* get() { return ptr_.get(); }
86
87 private:
88 std::unique_ptr<SearchProviderInstallStateImpl,
89 content::BrowserThread::DeleteOnIOThread>
90 ptr_;
91
92 DISALLOW_COPY_AND_ASSIGN(SearchProviderInstallStateImplAdapter);
93 };
94
95 #endif // CHROME_BROWSER_SEARCH_ENGINES_SEARCH_PROVIDER_INSTALL_STATE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698