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

Side by Side Diff: chromeos/components/tether/keep_alive_operation.cc

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 unified diff | Download patch
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 #include "chromeos/components/tether/keep_alive_operation.h" 5 #include "chromeos/components/tether/keep_alive_operation.h"
6 6
7 #include "chromeos/components/tether/message_wrapper.h" 7 #include "chromeos/components/tether/message_wrapper.h"
8 #include "chromeos/components/tether/proto/tether.pb.h" 8 #include "chromeos/components/tether/proto/tether.pb.h"
9 #include "components/proximity_auth/logging/logging.h" 9 #include "components/proximity_auth/logging/logging.h"
10 10
(...skipping 30 matching lines...) Expand all
41 41
42 KeepAliveOperation::KeepAliveOperation( 42 KeepAliveOperation::KeepAliveOperation(
43 const cryptauth::RemoteDevice& device_to_connect, 43 const cryptauth::RemoteDevice& device_to_connect,
44 BleConnectionManager* connection_manager) 44 BleConnectionManager* connection_manager)
45 : MessageTransferOperation( 45 : MessageTransferOperation(
46 std::vector<cryptauth::RemoteDevice>{device_to_connect}, 46 std::vector<cryptauth::RemoteDevice>{device_to_connect},
47 connection_manager) {} 47 connection_manager) {}
48 48
49 KeepAliveOperation::~KeepAliveOperation() {} 49 KeepAliveOperation::~KeepAliveOperation() {}
50 50
51 void KeepAliveOperation::AddObserver(Observer* observer) {
52 observer_list_.AddObserver(observer);
53 }
54
55 void KeepAliveOperation::RemoveObserver(Observer* observer) {
56 observer_list_.RemoveObserver(observer);
57 }
58
51 void KeepAliveOperation::OnDeviceAuthenticated( 59 void KeepAliveOperation::OnDeviceAuthenticated(
52 const cryptauth::RemoteDevice& remote_device) { 60 const cryptauth::RemoteDevice& remote_device) {
53 DCHECK(remote_devices().size() == 1u && remote_devices()[0] == remote_device); 61 DCHECK(remote_devices().size() == 1u && remote_devices()[0] == remote_device);
54 62
55 SendMessageToDevice(remote_device, 63 SendMessageToDevice(remote_device,
56 base::MakeUnique<MessageWrapper>(KeepAliveTickle())); 64 base::MakeUnique<MessageWrapper>(KeepAliveTickle()));
65 UnregisterDevice(remote_device);
66 }
67
68 void KeepAliveOperation::OnOperationFinished() {
69 for (auto& observer : observer_list_) {
70 observer.OnOperationFinished();
71 }
57 } 72 }
58 73
59 MessageType KeepAliveOperation::GetMessageTypeForConnection() { 74 MessageType KeepAliveOperation::GetMessageTypeForConnection() {
60 return MessageType::KEEP_ALIVE_TICKLE; 75 return MessageType::KEEP_ALIVE_TICKLE;
61 } 76 }
62 77
63 } // namespace tether 78 } // namespace tether
64 79
65 } // namespace chromeos 80 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/components/tether/keep_alive_operation.h ('k') | chromeos/components/tether/keep_alive_operation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698