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

Side by Side Diff: components/signin/core/browser/device_activity_fetcher.h

Issue 1087933002: Cross Device Promo - Main Eligibility Flow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: first set of anthony's comments Created 5 years, 7 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_SIGNIN_CORE_BROWSER_DEVICE_ACTVITIY_FETCHER_H_
6 #define COMPONENTS_SIGNIN_CORE_BROWSER_DEVICE_ACTVITIY_FETCHER_H_
7
8 #include <vector>
9
10 #include "base/time/time.h"
11 #include "base/timer/timer.h"
12 #include "google_apis/gaia/gaia_auth_consumer.h"
13 #include "net/base/backoff_entry.h"
14 #include "net/url_request/url_fetcher_delegate.h"
15
16 class GaiaAuthFetcher;
17 class SigninClient;
18
19 namespace net {
20 class URLFetcher;
21 }
22
23 class DeviceActivityFetcher : public GaiaAuthConsumer,
24 public net::URLFetcherDelegate {
25 public:
26 struct DeviceActivity {
27 base::Time last_active;
28 std::string name;
29 };
30
31 class Observer {
32 public:
33 virtual void OnFetchDeviceActivitySuccess(
34 const std::vector<DeviceActivityFetcher::DeviceActivity>& devices) = 0;
35 virtual void OnFetchDeviceActivityFailure() {}
36 };
37
38 DeviceActivityFetcher(SigninClient* signin_client,
39 DeviceActivityFetcher::Observer* observer);
40 ~DeviceActivityFetcher() override;
41
42 void Start();
43
44 // Overridden from GaiaAuthConsumer
45 void OnListIdpSessionsSuccess(const std::string& login_hint) override;
46 void OnListIdpSessionsError(const GoogleServiceAuthError& error) override;
47 void OnGetTokenResponseSuccess(const ClientOAuthResult& result) override;
48 void OnGetTokenResponseError(const GoogleServiceAuthError& error) override;
49
50 // Overridden from URLFetcherDelegate
51 void OnURLFetchComplete(const net::URLFetcher* source) override;
52
53 private:
54 void StartFetchingListIdpSessions();
55 void StartFetchingGetTokenResponse();
56 void StartFetchingListDevices();
57
58 // Gaia fetcher used for acquiring an access token.
59 scoped_ptr<GaiaAuthFetcher> gaia_auth_fetcher_;
60 // URL Fetcher used for calling List Devices.
61 scoped_ptr<net::URLFetcher> url_fetcher_;
62
63 // If either fetcher fails, retry with exponential backoff.
64 net::BackoffEntry fetcher_backoff_;
65 base::OneShotTimer<DeviceActivityFetcher> fetcher_timer_;
66 int fetcher_retries_;
67
68 std::string access_token_;
69 std::string login_hint_;
70
71 SigninClient* signin_client_; // Weak pointer.
72 Observer* observer_;
73
74 DISALLOW_COPY_AND_ASSIGN(DeviceActivityFetcher);
75 };
76
77 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_DEVICE_ACTVITIY_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698