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

Side by Side Diff: chrome/browser/chromeos/tether/tether_service.h

Issue 2961733002: [CrOS Tether] Remove spammy log from Initializer. (Closed)
Patch Set: hansberry@ comments. Created 3 years, 5 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/tether/tether_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_CHROMEOS_TETHER_TETHER_SERVICE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_TETHER_TETHER_SERVICE_H_
6 #define CHROME_BROWSER_CHROMEOS_TETHER_TETHER_SERVICE_H_ 6 #define CHROME_BROWSER_CHROMEOS_TETHER_TETHER_SERVICE_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "chromeos/dbus/power_manager_client.h" 13 #include "chromeos/dbus/power_manager_client.h"
14 #include "chromeos/dbus/session_manager_client.h" 14 #include "chromeos/dbus/session_manager_client.h"
15 #include "chromeos/network/network_state_handler.h" 15 #include "chromeos/network/network_state_handler.h"
16 #include "chromeos/network/network_state_handler_observer.h" 16 #include "chromeos/network/network_state_handler_observer.h"
17 #include "components/cryptauth/cryptauth_device_manager.h" 17 #include "components/cryptauth/cryptauth_device_manager.h"
18 #include "components/keyed_service/core/keyed_service.h" 18 #include "components/keyed_service/core/keyed_service.h"
19 #include "components/prefs/pref_change_registrar.h" 19 #include "components/prefs/pref_change_registrar.h"
20 #include "device/bluetooth/bluetooth_adapter.h" 20 #include "device/bluetooth/bluetooth_adapter.h"
21 21
22 namespace chromeos {
23 class NetworkStateHandler;
24 class ManagedNetworkConfigurationHandler;
25 class NetworkConnect;
26 class NetworkConnectionHandler;
27 namespace tether {
28 class NotificationPresenter;
29 } // namespace tether
30 } // namespace chromeos
31
22 namespace cryptauth { 32 namespace cryptauth {
23 class CryptAuthService; 33 class CryptAuthService;
24 } // cryptauth 34 } // namespace cryptauth
25 35
26 class PrefRegistrySimple; 36 class PrefRegistrySimple;
27 class Profile; 37 class Profile;
38 class ProfileOAuth2TokenService;
28 39
29 class TetherService : public KeyedService, 40 class TetherService : public KeyedService,
30 public chromeos::PowerManagerClient::Observer, 41 public chromeos::PowerManagerClient::Observer,
31 public chromeos::SessionManagerClient::Observer, 42 public chromeos::SessionManagerClient::Observer,
32 public cryptauth::CryptAuthDeviceManager::Observer, 43 public cryptauth::CryptAuthDeviceManager::Observer,
33 public device::BluetoothAdapter::Observer, 44 public device::BluetoothAdapter::Observer,
34 public chromeos::NetworkStateHandlerObserver { 45 public chromeos::NetworkStateHandlerObserver {
35 public: 46 public:
36 TetherService(Profile* profile, 47 TetherService(Profile* profile,
37 chromeos::PowerManagerClient* power_manager_client, 48 chromeos::PowerManagerClient* power_manager_client,
(...skipping 12 matching lines...) Expand all
50 static bool IsFeatureFlagEnabled(); 61 static bool IsFeatureFlagEnabled();
51 62
52 // Attempt to start the Tether module. Only succeeds if all conditions to 63 // Attempt to start the Tether module. Only succeeds if all conditions to
53 // reach chromeos::NetworkStateHandler::TechnologyState::ENABLED are reached. 64 // reach chromeos::NetworkStateHandler::TechnologyState::ENABLED are reached.
54 // Should only be called once a user is logged in. 65 // Should only be called once a user is logged in.
55 virtual void StartTetherIfEnabled(); 66 virtual void StartTetherIfEnabled();
56 67
57 // Stop the Tether module. 68 // Stop the Tether module.
58 virtual void StopTether(); 69 virtual void StopTether();
59 70
71 // Delegate used to call the static functions of Initializer. Injected to
72 // aid in testing.
73 class InitializerDelegate {
74 public:
75 virtual void InitializeTether(
76 cryptauth::CryptAuthService* cryptauth_service,
77 std::unique_ptr<chromeos::tether::NotificationPresenter>
78 notification_presenter,
79 PrefService* pref_service,
80 ProfileOAuth2TokenService* token_service,
81 chromeos::NetworkStateHandler* network_state_handler,
82 chromeos::ManagedNetworkConfigurationHandler*
83 managed_network_configuration_handler,
84 chromeos::NetworkConnect* network_connect,
85 chromeos::NetworkConnectionHandler* network_connection_handler);
86 virtual void ShutdownTether();
87 };
88
60 protected: 89 protected:
61 // KeyedService: 90 // KeyedService:
62 void Shutdown() override; 91 void Shutdown() override;
63 92
64 // chromeos::PowerManagerClient::Observer: 93 // chromeos::PowerManagerClient::Observer:
65 void SuspendImminent() override; 94 void SuspendImminent() override;
66 void SuspendDone(const base::TimeDelta& sleep_duration) override; 95 void SuspendDone(const base::TimeDelta& sleep_duration) override;
67 96
68 // chromeos::SessionManagerClient::Observer: 97 // chromeos::SessionManagerClient::Observer:
69 void ScreenIsLocked() override; 98 void ScreenIsLocked() override;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 bool IsCellularAvailableButNotEnabled() const; 135 bool IsCellularAvailableButNotEnabled() const;
107 136
108 // Whether Tether is allowed to be used. If the controlling preference 137 // Whether Tether is allowed to be used. If the controlling preference
109 // is set (from policy), this returns the preference value. Otherwise, it is 138 // is set (from policy), this returns the preference value. Otherwise, it is
110 // permitted if the flag is enabled. 139 // permitted if the flag is enabled.
111 bool IsAllowedByPolicy() const; 140 bool IsAllowedByPolicy() const;
112 141
113 // Whether Tether is enabled. 142 // Whether Tether is enabled.
114 bool IsEnabledbyPreference() const; 143 bool IsEnabledbyPreference() const;
115 144
145 void SetInitializerDelegateForTest(
146 std::unique_ptr<InitializerDelegate> initializer_delegate);
147
116 // Whether the service has been shut down. 148 // Whether the service has been shut down.
117 bool shut_down_ = false; 149 bool shut_down_ = false;
118 150
119 // Whether the device and service have been suspended (e.g. the laptop lid 151 // Whether the device and service have been suspended (e.g. the laptop lid
120 // was closed). 152 // was closed).
121 bool suspended_ = false; 153 bool suspended_ = false;
122 154
123 Profile* profile_; 155 Profile* profile_;
124 chromeos::PowerManagerClient* power_manager_client_; 156 chromeos::PowerManagerClient* power_manager_client_;
125 chromeos::SessionManagerClient* session_manager_client_; 157 chromeos::SessionManagerClient* session_manager_client_;
126 cryptauth::CryptAuthService* cryptauth_service_; 158 cryptauth::CryptAuthService* cryptauth_service_;
127 chromeos::NetworkStateHandler* network_state_handler_; 159 chromeos::NetworkStateHandler* network_state_handler_;
160 std::unique_ptr<InitializerDelegate> initializer_delegate_;
128 161
129 PrefChangeRegistrar registrar_; 162 PrefChangeRegistrar registrar_;
130 scoped_refptr<device::BluetoothAdapter> adapter_; 163 scoped_refptr<device::BluetoothAdapter> adapter_;
131 164
132 base::WeakPtrFactory<TetherService> weak_ptr_factory_; 165 base::WeakPtrFactory<TetherService> weak_ptr_factory_;
133 166
134 DISALLOW_COPY_AND_ASSIGN(TetherService); 167 DISALLOW_COPY_AND_ASSIGN(TetherService);
135 }; 168 };
136 169
137 #endif // CHROME_BROWSER_CHROMEOS_TETHER_TETHER_SERVICE_H_ 170 #endif // CHROME_BROWSER_CHROMEOS_TETHER_TETHER_SERVICE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/tether/tether_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698