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

Unified 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, 8 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 side-by-side diff with in-line comments
Download patch
Index: chromeos/components/tether/tether_host_response_recorder.h
diff --git a/chromeos/components/tether/tether_host_response_recorder.h b/chromeos/components/tether/tether_host_response_recorder.h
new file mode 100644
index 0000000000000000000000000000000000000000..f87dd936ccc7777b3ef6aa67c41d0b0069739955
--- /dev/null
+++ b/chromeos/components/tether/tether_host_response_recorder.h
@@ -0,0 +1,77 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROMEOS_COMPONENTS_TETHER_TETHER_HOST_RESPONSE_RECORDER_H_
+#define CHROMEOS_COMPONENTS_TETHER_TETHER_HOST_RESPONSE_RECORDER_H_
+
+#include <string>
+#include <vector>
+
+#include "base/macros.h"
+#include "components/cryptauth/remote_device.h"
+
+class PrefService;
+class PrefRegistrySimple;
+
+namespace chromeos {
+
+namespace tether {
+
+// Records responses from tether hosts in user prefs, which persists these
+// responses between reboots of the device. When a TetherAvailabilityResponse or
+// ConnectTetheringResponse is received, it should be recorded using this class.
+// Responses can be retrieved at a later time via getter methods.
+class TetherHostResponseRecorder {
+ public:
+ // Note: The PrefService* passed here must be created using the same registry
+ // passed to RegisterPrefs().
+ TetherHostResponseRecorder(PrefService* pref_service);
+ virtual ~TetherHostResponseRecorder();
+
+ // Registers the prefs used by this class to |registry|. Must be called before
+ // this class is utilized.
+ static void RegisterPrefs(PrefRegistrySimple* registry);
+
+ // Records a TetherAvailabilityResponse. This function should be called each
+ // time that a response is received from a potential host, even if a
+ // connection is not started.
+ virtual void RecordSuccessfulTetherAvailabilityResponse(
+ const cryptauth::RemoteDevice& remote_device);
+
+ // Gets device IDs corresponding to hosts which have sent
+ // TetherAvailabilityResponses with a response code indicating that tethering
+ // is available. The list is sorted; the IDs of the devices which have
+ // responded most recently are at the front of the list and the IDs of the
+ // devices which have responded least recently are at the end of the list.
+ virtual std::vector<std::string> GetPreviouslyAvailableHostIds() const;
+
+ // Records a ConnectTetheringResponse. This function should be called each
+ // time that a response is received from a host.
+ virtual void RecordSuccessfulConnectTetheringResponse(
+ const cryptauth::RemoteDevice& remote_device);
+
+ // Gets device IDs corresponding to hosts which have sent
+ // ConnectTetheringResponses with a response code indicating that they have
+ // successfully turned on their Wi-Fi hotspots. The list is sorted; the IDs of
+ // the devices which have responded most recently are at the front of the list
+ // and the IDs of the devices which have responded least recently are at the
+ // end of the list.
+ virtual std::vector<std::string> GetPreviouslyConnectedHostIds() const;
+
+ private:
+ void AddRecentResponse(const std::string& device_id,
+ const std::string& pref_name);
+ std::vector<std::string> GetDeviceIdsForPref(
+ const std::string& pref_name) const;
+
+ PrefService* pref_service_;
+
+ DISALLOW_COPY_AND_ASSIGN(TetherHostResponseRecorder);
+};
+
+} // namespace tether
+
+} // namespace chromeos
+
+#endif // CHROMEOS_COMPONENTS_TETHER_TETHER_HOST_RESPONSE_RECORDER_H_
« 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