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

Side by Side Diff: components/browser_sync/browser/signin_confirmation_helper.h

Issue 2345843003: [Sync] Merge //components/browser_sync into one directory. (Closed)
Patch Set: Address comment + rebase. Created 4 years, 3 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 2015 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 COMPONENTS_BROWSER_SYNC_BROWSER_SIGNIN_CONFIRMATION_HELPER_
6 #define COMPONENTS_BROWSER_SYNC_BROWSER_SIGNIN_CONFIRMATION_HELPER_
7
8 #include <stddef.h>
9
10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/task/cancelable_task_tracker.h"
13
14 namespace history {
15 class HistoryService;
16 class QueryResults;
17 }
18
19 namespace sync_driver {
20
21 // Helper class for sync signin to check some asynchronous conditions. Call
22 // either CheckHasHistory or CheckHasTypedUrls or both, and |return_result|
23 // will be called with true if either returns true, otherwise false.
24 class SigninConfirmationHelper {
25 public:
26 SigninConfirmationHelper(history::HistoryService* history_service,
27 const base::Callback<void(bool)>& return_result);
28
29 // This helper checks if there are history entries in the history service.
30 void CheckHasHistory(int max_entries);
31
32 // This helper checks if there are typed URLs in the history service.
33 void CheckHasTypedURLs();
34
35 private:
36 // Deletes itself.
37 ~SigninConfirmationHelper();
38
39 // Callback helper function for CheckHasHistory.
40 void OnHistoryQueryResults(size_t max_entries,
41 history::QueryResults* results);
42
43 // Posts the given result to the origin thread.
44 void PostResult(bool result);
45
46 // Calls |return_result_| if |result| == true or if it's the result of the
47 // last pending check.
48 void ReturnResult(bool result);
49
50 // The task runner for the thread this object was constructed on.
51 const scoped_refptr<base::SingleThreadTaskRunner> origin_thread_;
52
53 // Pointer to the history service.
54 history::HistoryService* history_service_;
55
56 // Used for async tasks.
57 base::CancelableTaskTracker task_tracker_;
58
59 // Keep track of how many async requests are pending.
60 int pending_requests_;
61
62 // Callback to pass the result back to the caller.
63 const base::Callback<void(bool)> return_result_;
64
65 DISALLOW_COPY_AND_ASSIGN(SigninConfirmationHelper);
66 };
67
68 } // namespace sync_driver
69
70 #endif // COMPONENTS_BROWSER_SYNC_BROWSER_SIGNIN_CONFIRMATION_HELPER_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698