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

Side by Side Diff: chromeos/components/tether/tether_host_response_recorder.h

Issue 2844973002: [CrOS Tether] Create TetherHostResponseRecorder, which records ConnectTetheringResponses and Tether… (Closed)
Patch Set: Changed "Connectable" wording to "Connected". Created 3 years, 7 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROMEOS_COMPONENTS_TETHER_TETHER_HOST_RESPONSE_RECORDER_H_
6 #define CHROMEOS_COMPONENTS_TETHER_TETHER_HOST_RESPONSE_RECORDER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/macros.h"
12 #include "components/cryptauth/remote_device.h"
13
14 class PrefService;
15 class PrefRegistrySimple;
16
17 namespace chromeos {
18
19 namespace tether {
20
21 // Records responses from tether hosts in user prefs, which persists these
22 // responses between reboots of the device. When a TetherAvailabilityResponse or
23 // ConnectTetheringResponse is received, it should be recorded using this class.
24 // Responses can be retrieved at a later time via getter methods.
25 class TetherHostResponseRecorder {
26 public:
27 // Note: The PrefService* passed here must be created using the same registry
28 // passed to RegisterPrefs().
29 TetherHostResponseRecorder(PrefService* pref_service);
30 virtual ~TetherHostResponseRecorder();
31
32 // Registers the prefs used by this class to |registry|. Must be called before
33 // this class is utilized.
34 static void RegisterPrefs(PrefRegistrySimple* registry);
35
36 // Records a TetherAvailabilityResponse. This function should be called each
37 // time that a response is received from a potential host, even if a
38 // connection is not started.
39 virtual void RecordSuccessfulTetherAvailabilityResponse(
40 const cryptauth::RemoteDevice& remote_device);
41
42 // Gets device IDs corresponding to hosts which have sent
43 // TetherAvailabilityResponses with a response code indicating that tethering
44 // is available. The list is sorted; the IDs of the devices which have
45 // responded most recently are at the front of the list and the IDs of the
46 // devices which have responded least recently are at the end of the list.
47 virtual std::vector<std::string> GetPreviouslyAvailableHostIds() const;
48
49 // Records a ConnectTetheringResponse. This function should be called each
50 // time that a response is received from a host.
51 virtual void RecordSuccessfulConnectTetheringResponse(
52 const cryptauth::RemoteDevice& remote_device);
53
54 // Gets device IDs corresponding to hosts which have sent
55 // ConnectTetheringResponses with a response code indicating that they have
56 // successfully turned on their Wi-Fi hotspots. The list is sorted; the IDs of
57 // the devices which have responded most recently are at the front of the list
58 // and the IDs of the devices which have responded least recently are at the
59 // end of the list.
60 virtual std::vector<std::string> GetPreviouslyConnectedHostIds() const;
61
62 private:
63 void AddRecentResponse(const std::string& device_id,
64 const std::string& pref_name);
65 std::vector<std::string> GetDeviceIdsForPref(
66 const std::string& pref_name) const;
67
68 PrefService* pref_service_;
69
70 DISALLOW_COPY_AND_ASSIGN(TetherHostResponseRecorder);
71 };
72
73 } // namespace tether
74
75 } // namespace chromeos
76
77 #endif // CHROMEOS_COMPONENTS_TETHER_TETHER_HOST_RESPONSE_RECORDER_H_
OLDNEW
« no previous file with comments | « chromeos/components/tether/tether_connector_unittest.cc ('k') | chromeos/components/tether/tether_host_response_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698