Adding instrumentation to locate the source of jankiness
[chromium-blink-merge.git] / chrome / browser / signin / easy_unlock_toggle_flow.h
blob303b843c514ed82544254cdb1bc128b76c12e2db
1 // Copyright 2014 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.
5 #ifndef CHROME_BROWSER_SIGNIN_EASY_UNLOCK_TOGGLE_FLOW_H_
6 #define CHROME_BROWSER_SIGNIN_EASY_UNLOCK_TOGGLE_FLOW_H_
8 #include <string>
9 #include <vector>
11 #include "base/callback.h"
12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "google_apis/gaia/google_service_auth_error.h"
15 #include "google_apis/gaia/oauth2_mint_token_flow.h"
16 #include "google_apis/gaia/oauth2_token_service.h"
18 class Profile;
20 class EasyUnlockToggleFlow : public OAuth2TokenService::Consumer,
21 public OAuth2MintTokenFlow::Delegate {
22 public:
23 // Callback to indicate whether the call succeeds or not.
24 typedef base::Callback<void(bool)> ToggleFlowCallback;
26 EasyUnlockToggleFlow(Profile* profile,
27 const std::string& phone_public_key,
28 bool toggle_enable,
29 const ToggleFlowCallback& callback);
30 virtual ~EasyUnlockToggleFlow();
32 void Start();
34 // OAuth2TokenService::Consumer
35 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
36 const std::string& access_token,
37 const base::Time& expiration_time) override;
38 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request,
39 const GoogleServiceAuthError& error) override;
41 // OAuth2MintTokenFlow::Delegate
42 virtual void OnMintTokenSuccess(const std::string& access_token,
43 int time_to_live) override;
44 virtual void OnMintTokenFailure(
45 const GoogleServiceAuthError& error) override;
46 virtual void OnIssueAdviceSuccess(
47 const IssueAdviceInfo& issue_advice) override;
49 private:
50 // Derived OAuth2ApiCallFlow class to make toggle api call after access token
51 // is available.
52 class ToggleApiCall;
54 // Callbacks from ToggleApiCall
55 void ReportToggleApiCallResult(bool success);
57 Profile* profile_;
58 const std::string phone_public_key_;
59 const bool toggle_enable_;
60 ToggleFlowCallback callback_;
62 scoped_ptr<OAuth2TokenService::Request> token_request_;
63 scoped_ptr<OAuth2MintTokenFlow> mint_token_flow_;
64 scoped_ptr<ToggleApiCall> toggle_api_call_;
66 DISALLOW_COPY_AND_ASSIGN(EasyUnlockToggleFlow);
69 #endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_TOGGLE_FLOW_H_