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

Unified Diff: chromeos/components/tether/keep_alive_scheduler.h

Issue 2741253002: [CrOS Tether] Create KeepAliveScheduler, a class which schedules keep-alive tickles to be sent to a… (Closed)
Patch Set: Add missing dependency. Created 3 years, 9 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/keep_alive_scheduler.h
diff --git a/chromeos/components/tether/keep_alive_scheduler.h b/chromeos/components/tether/keep_alive_scheduler.h
new file mode 100644
index 0000000000000000000000000000000000000000..9232a66746c5dc468daf747052cee2f204e582de
--- /dev/null
+++ b/chromeos/components/tether/keep_alive_scheduler.h
@@ -0,0 +1,66 @@
+// 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_KEEP_ALIVE_SCHEDULER_H_
+#define CHROMEOS_COMPONENTS_TETHER_KEEP_ALIVE_SCHEDULER_H_
+
+#include <memory>
+
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "base/timer/timer.h"
+#include "chromeos/components/tether/active_host.h"
+#include "chromeos/components/tether/keep_alive_operation.h"
+
+namespace chromeos {
+
+namespace tether {
+
+// Schedules keep-alive messages to be sent when this device is connected to a
+// remote device's tether hotspot. When a device connects, a keep-alive message
+// is sent immediately, then another one is scheduled every 4 minutes until the
+// device disconnects.
+class KeepAliveScheduler : public ActiveHost::Observer,
+ public KeepAliveOperation::Observer {
+ public:
+ KeepAliveScheduler(ActiveHost* active_host,
+ BleConnectionManager* connection_manager);
+ virtual ~KeepAliveScheduler();
+
+ // ActiveHost::Observer:
+ void OnActiveHostChanged(ActiveHost::ActiveHostStatus active_host_status,
+ std::unique_ptr<cryptauth::RemoteDevice> active_host,
+ const std::string& wifi_network_id) override;
+
+ // KeepAliveOperation::Observer:
+ void OnOperationFinished() override;
+
+ private:
+ friend class KeepAliveSchedulerTest;
+
+ KeepAliveScheduler(ActiveHost* active_host,
+ BleConnectionManager* connection_manager,
+ std::unique_ptr<base::Timer> timer);
+
+ void SendKeepAliveTickle();
+
+ static const uint32_t kKeepAliveIntervalMinutes;
+
+ ActiveHost* active_host_;
+ BleConnectionManager* connection_manager_;
+
+ std::unique_ptr<base::Timer> timer_;
+ std::unique_ptr<cryptauth::RemoteDevice> active_host_device_;
+ std::unique_ptr<KeepAliveOperation> keep_alive_operation_;
+
+ base::WeakPtrFactory<KeepAliveScheduler> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(KeepAliveScheduler);
+};
+
+} // namespace tether
+
+} // namespace chromeos
+
+#endif // CHROMEOS_COMPONENTS_TETHER_KEEP_ALIVE_SCHEDULER_H_
« no previous file with comments | « chromeos/components/tether/keep_alive_operation_unittest.cc ('k') | chromeos/components/tether/keep_alive_scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698