OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_POLICY_SERVER_BACKED_STATE_KEYS_BROKER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_SERVER_BACKED_STATE_KEYS_BROKER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_POLICY_SERVER_BACKED_STATE_KEYS_BROKER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_SERVER_BACKED_STATE_KEYS_BROKER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 28 matching lines...) Expand all Loading... |
39 chromeos::SessionManagerClient* session_manager_client, | 39 chromeos::SessionManagerClient* session_manager_client, |
40 scoped_refptr<base::TaskRunner> delayed_task_runner); | 40 scoped_refptr<base::TaskRunner> delayed_task_runner); |
41 ~ServerBackedStateKeysBroker(); | 41 ~ServerBackedStateKeysBroker(); |
42 | 42 |
43 // Registers a callback to be invoked whenever the state keys get updated. | 43 // Registers a callback to be invoked whenever the state keys get updated. |
44 // Note that consuming code needs to hold on to the returned Subscription as | 44 // Note that consuming code needs to hold on to the returned Subscription as |
45 // long as it wants to receive the callback. If the state keys haven't been | 45 // long as it wants to receive the callback. If the state keys haven't been |
46 // requested yet, calling this will also trigger their initial fetch. | 46 // requested yet, calling this will also trigger their initial fetch. |
47 Subscription RegisterUpdateCallback(const base::Closure& callback); | 47 Subscription RegisterUpdateCallback(const base::Closure& callback); |
48 | 48 |
49 // Requests state keys asynchronously. Invokes the passed callback exactly | 49 // Requests state keys asynchronously. Invokes the passed callback at most |
50 // once (unless |this| gets destroyed before the callback happens), with the | 50 // once, with the current state keys passed as a parameter to the callback. If |
51 // current state keys passed as a parameter to the callback. If there's a | 51 // there's a problem determining the state keys, the passed vector will be |
52 // problem determining the state keys, the passed vector will be empty. | 52 // empty. If |this| gets destroyed before the callback happens or if the time |
| 53 // sync fails / the network is not established, then the |callback| is never |
| 54 // invoked. See http://crbug.com/649422 for more context. |
53 void RequestStateKeys(const StateKeysCallback& callback); | 55 void RequestStateKeys(const StateKeysCallback& callback); |
54 | 56 |
55 // Get the set of current state keys. Empty if state keys are unavailable | 57 // Get the set of current state keys. Empty if state keys are unavailable |
56 // or pending retrieval. | 58 // or pending retrieval. |
57 const std::vector<std::string>& state_keys() const { return state_keys_; } | 59 const std::vector<std::string>& state_keys() const { return state_keys_; } |
58 | 60 |
59 // Returns the state key for the current point in time. Returns an empty | 61 // Returns the state key for the current point in time. Returns an empty |
60 // string if state keys are unavailable or pending retrieval. | 62 // string if state keys are unavailable or pending retrieval. |
61 std::string current_state_key() const { | 63 std::string current_state_key() const { |
62 return state_keys_.empty() ? std::string() : state_keys_.front(); | 64 return state_keys_.empty() ? std::string() : state_keys_.front(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 std::vector<StateKeysCallback> request_callbacks_; | 97 std::vector<StateKeysCallback> request_callbacks_; |
96 | 98 |
97 base::WeakPtrFactory<ServerBackedStateKeysBroker> weak_factory_; | 99 base::WeakPtrFactory<ServerBackedStateKeysBroker> weak_factory_; |
98 | 100 |
99 DISALLOW_COPY_AND_ASSIGN(ServerBackedStateKeysBroker); | 101 DISALLOW_COPY_AND_ASSIGN(ServerBackedStateKeysBroker); |
100 }; | 102 }; |
101 | 103 |
102 } // namespace policy | 104 } // namespace policy |
103 | 105 |
104 #endif // CHROME_BROWSER_CHROMEOS_POLICY_SERVER_BACKED_STATE_KEYS_BROKER_H_ | 106 #endif // CHROME_BROWSER_CHROMEOS_POLICY_SERVER_BACKED_STATE_KEYS_BROKER_H_ |
OLD | NEW |