OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_PROXIMITY_AUTH_CRYPTAUTH_SYNC_SCHEDULER_H | 5 #ifndef COMPONENTS_PROXIMITY_AUTH_CRYPTAUTH_SYNC_SCHEDULER_H |
6 #define COMPONENTS_PROXIMITY_AUTH_CRYPTAUTH_SYNC_SCHEDULER_H | 6 #define COMPONENTS_PROXIMITY_AUTH_CRYPTAUTH_SYNC_SCHEDULER_H |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
11 #include "base/time/time.h" | 12 #include "base/time/time.h" |
12 | 13 |
13 namespace proximity_auth { | 14 namespace proximity_auth { |
14 | 15 |
15 // Interface for scheduling the next CryptAuth sync (e.g. enrollment or device | 16 // Interface for scheduling the next CryptAuth sync (e.g. enrollment or device |
16 // sync). The scheduler has two different strategies affecting when to perform | 17 // sync). The scheduler has two different strategies affecting when to perform |
17 // the next operation: | 18 // the next operation: |
18 // PERIODIC_REFRESH: The last sync was made successfully, so we can wait a | 19 // PERIODIC_REFRESH: The last sync was made successfully, so we can wait a |
19 // relatively long time before making another sync. | 20 // relatively long time before making another sync. |
(...skipping 29 matching lines...) Expand all Loading... |
49 DISALLOW_COPY_AND_ASSIGN(SyncRequest); | 50 DISALLOW_COPY_AND_ASSIGN(SyncRequest); |
50 }; | 51 }; |
51 | 52 |
52 // Handles the actual sync operation. | 53 // Handles the actual sync operation. |
53 class Delegate { | 54 class Delegate { |
54 public: | 55 public: |
55 virtual ~Delegate() {} | 56 virtual ~Delegate() {} |
56 | 57 |
57 // Called when the scheduler fires and requests a sync attempt. The delegate | 58 // Called when the scheduler fires and requests a sync attempt. The delegate |
58 // should call sync_request->Complete() when the request finishes. | 59 // should call sync_request->Complete() when the request finishes. |
59 virtual void OnSyncRequested(scoped_ptr<SyncRequest> sync_request) = 0; | 60 virtual void OnSyncRequested(std::unique_ptr<SyncRequest> sync_request) = 0; |
60 }; | 61 }; |
61 | 62 |
62 virtual ~SyncScheduler() {} | 63 virtual ~SyncScheduler() {} |
63 | 64 |
64 // Starts the scheduler with an aggressive recovery strategy if | 65 // Starts the scheduler with an aggressive recovery strategy if |
65 // |strategy| is true; otherwise, it will be started with | 66 // |strategy| is true; otherwise, it will be started with |
66 // periodic refresh. | 67 // periodic refresh. |
67 // | 68 // |
68 // |elapsed_time_since_last_sync| is the time since the last successful sync, | 69 // |elapsed_time_since_last_sync| is the time since the last successful sync, |
69 // so we can determine the duration of the first sync period. For example, the | 70 // so we can determine the duration of the first sync period. For example, the |
(...skipping 18 matching lines...) Expand all Loading... |
88 virtual SyncState GetSyncState() const = 0; | 89 virtual SyncState GetSyncState() const = 0; |
89 | 90 |
90 protected: | 91 protected: |
91 // Called by SyncRequest instances when the sync completes. | 92 // Called by SyncRequest instances when the sync completes. |
92 virtual void OnSyncCompleted(bool success) = 0; | 93 virtual void OnSyncCompleted(bool success) = 0; |
93 }; | 94 }; |
94 | 95 |
95 } // namespace proximity_auth | 96 } // namespace proximity_auth |
96 | 97 |
97 #endif // COMPONENTS_PROXIMITY_CRYPTAUTH_SYNC_SCHEDULER_H | 98 #endif // COMPONENTS_PROXIMITY_CRYPTAUTH_SYNC_SCHEDULER_H |
OLD | NEW |