| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_BROWSER_PROFILE_RESETTER_BRANDCODE_CONFIG_FETCHER_H_ | 5 #ifndef CHROME_BROWSER_PROFILE_RESETTER_BRANDCODE_CONFIG_FETCHER_H_ |
| 6 #define CHROME_BROWSER_PROFILE_RESETTER_BRANDCODE_CONFIG_FETCHER_H_ | 6 #define CHROME_BROWSER_PROFILE_RESETTER_BRANDCODE_CONFIG_FETCHER_H_ |
| 7 | 7 |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/timer/timer.h" | 12 #include "base/timer/timer.h" |
| 13 #include "net/url_request/url_fetcher_delegate.h" | 13 #include "net/url_request/url_fetcher_delegate.h" |
| 14 | 14 |
| 15 class BrandcodedDefaultSettings; | 15 class BrandcodedDefaultSettings; |
| 16 class GURL; | 16 class GURL; |
| 17 | 17 |
| 18 // BrandcodeConfigFetcher fetches and parses the xml containing the brandcoded | 18 // BrandcodeConfigFetcher fetches and parses the xml containing the brandcoded |
| 19 // default settings. Caller should provide a FetchCallback. | 19 // default settings. Caller should provide a FetchCallback. |
| 20 class BrandcodeConfigFetcher : public net::URLFetcherDelegate { | 20 class BrandcodeConfigFetcher : public net::URLFetcherDelegate { |
| 21 public: | 21 public: |
| 22 typedef base::Callback<void ()> FetchCallback; | 22 typedef base::Callback<void ()> FetchCallback; |
| 23 | 23 |
| 24 BrandcodeConfigFetcher(const FetchCallback& callback, | 24 BrandcodeConfigFetcher(const FetchCallback& callback, |
| 25 const GURL& url, | 25 const GURL& url, |
| 26 const std::string& brandcode); | 26 const std::string& brandcode); |
| 27 ~BrandcodeConfigFetcher() override; | 27 ~BrandcodeConfigFetcher() override; |
| 28 | 28 |
| 29 bool IsActive() const { return config_fetcher_; } | 29 bool IsActive() const { return !!config_fetcher_; } |
| 30 | 30 |
| 31 scoped_ptr<BrandcodedDefaultSettings> GetSettings() { | 31 scoped_ptr<BrandcodedDefaultSettings> GetSettings() { |
| 32 return std::move(default_settings_); | 32 return std::move(default_settings_); |
| 33 } | 33 } |
| 34 | 34 |
| 35 // Sets the new callback. The previous one won't be called. | 35 // Sets the new callback. The previous one won't be called. |
| 36 void SetCallback(const FetchCallback& callback); | 36 void SetCallback(const FetchCallback& callback); |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 // net::URLFetcherDelegate: | 39 // net::URLFetcherDelegate: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 51 // Helper to fetch the online config file. | 51 // Helper to fetch the online config file. |
| 52 scoped_ptr<net::URLFetcher> config_fetcher_; | 52 scoped_ptr<net::URLFetcher> config_fetcher_; |
| 53 | 53 |
| 54 // Fetched settings. | 54 // Fetched settings. |
| 55 scoped_ptr<BrandcodedDefaultSettings> default_settings_; | 55 scoped_ptr<BrandcodedDefaultSettings> default_settings_; |
| 56 | 56 |
| 57 DISALLOW_COPY_AND_ASSIGN(BrandcodeConfigFetcher); | 57 DISALLOW_COPY_AND_ASSIGN(BrandcodeConfigFetcher); |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 #endif // CHROME_BROWSER_PROFILE_RESETTER_BRANDCODE_CONFIG_FETCHER_H_ | 60 #endif // CHROME_BROWSER_PROFILE_RESETTER_BRANDCODE_CONFIG_FETCHER_H_ |
| OLD | NEW |