OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_SEARCH_ONE_GOOGLE_BAR_ONE_GOOGLE_BAR_FETCHER_IMPL_H_ |
| 6 #define CHROME_BROWSER_SEARCH_ONE_GOOGLE_BAR_ONE_GOOGLE_BAR_FETCHER_IMPL_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/macros.h" |
| 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/optional.h" |
| 15 #include "chrome/browser/search/one_google_bar/one_google_bar_fetcher.h" |
| 16 |
| 17 class GoogleURLTracker; |
| 18 class OAuth2TokenService; |
| 19 class SigninManagerBase; |
| 20 |
| 21 namespace base { |
| 22 class Value; |
| 23 } |
| 24 |
| 25 namespace net { |
| 26 class URLFetcher; |
| 27 class URLRequestContextGetter; |
| 28 } // namespace net |
| 29 |
| 30 struct OneGoogleBarData; |
| 31 |
| 32 class OneGoogleBarFetcherImpl : public OneGoogleBarFetcher { |
| 33 public: |
| 34 OneGoogleBarFetcherImpl(SigninManagerBase* signin_manager, |
| 35 OAuth2TokenService* token_service, |
| 36 net::URLRequestContextGetter* request_context, |
| 37 GoogleURLTracker* google_url_tracker); |
| 38 ~OneGoogleBarFetcherImpl(); |
| 39 |
| 40 void Fetch(OneGoogleCallback callback) override; |
| 41 |
| 42 private: |
| 43 class AuthenticatedURLFetcher; |
| 44 |
| 45 void IssueRequestIfNoneOngoing(); |
| 46 |
| 47 void FetchDone(const net::URLFetcher* source); |
| 48 |
| 49 void JsonParsed(std::unique_ptr<base::Value> value); |
| 50 void JsonParseFailed(const std::string& message); |
| 51 |
| 52 void Respond(const base::Optional<OneGoogleBarData>& data); |
| 53 |
| 54 SigninManagerBase* signin_manager_; |
| 55 OAuth2TokenService* token_service_; |
| 56 net::URLRequestContextGetter* request_context_; |
| 57 GoogleURLTracker* google_url_tracker_; |
| 58 |
| 59 std::vector<OneGoogleCallback> callbacks_; |
| 60 std::unique_ptr<AuthenticatedURLFetcher> pending_request_; |
| 61 |
| 62 base::WeakPtrFactory<OneGoogleBarFetcherImpl> weak_ptr_factory_; |
| 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(OneGoogleBarFetcherImpl); |
| 65 }; |
| 66 |
| 67 #endif // CHROME_BROWSER_SEARCH_ONE_GOOGLE_BAR_ONE_GOOGLE_BAR_FETCHER_IMPL_H_ |
OLD | NEW |