| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_GOOGLE_URL_TRACKER_H_ | 5 #ifndef CHROME_BROWSER_GOOGLE_URL_TRACKER_H_ |
| 6 #define CHROME_BROWSER_GOOGLE_URL_TRACKER_H_ | 6 #define CHROME_BROWSER_GOOGLE_URL_TRACKER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "chrome/browser/net/url_fetcher.h" | 10 #include "chrome/browser/net/url_fetcher.h" |
| 11 #include "chrome/common/notification_observer.h" | 11 #include "chrome/common/notification_registrar.h" |
| 12 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
| 13 #include "testing/gtest/include/gtest/gtest_prod.h" | 13 #include "testing/gtest/include/gtest/gtest_prod.h" |
| 14 | 14 |
| 15 class PrefService; | 15 class PrefService; |
| 16 | 16 |
| 17 // This object is responsible for updating the Google URL at most once per run, | 17 // This object is responsible for updating the Google URL at most once per run, |
| 18 // and tracking the currently known value, which is also saved to a pref. | 18 // and tracking the currently known value, which is also saved to a pref. |
| 19 // | 19 // |
| 20 // Most consumers should only call GoogleURL(), which is guaranteed to | 20 // Most consumers should only call GoogleURL(), which is guaranteed to |
| 21 // synchronously return a value at all times (even during startup or in unittest | 21 // synchronously return a value at all times (even during startup or in unittest |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 const ResponseCookies& cookies, | 83 const ResponseCookies& cookies, |
| 84 const std::string& data); | 84 const std::string& data); |
| 85 | 85 |
| 86 // NotificationObserver | 86 // NotificationObserver |
| 87 virtual void Observe(NotificationType type, | 87 virtual void Observe(NotificationType type, |
| 88 const NotificationSource& source, | 88 const NotificationSource& source, |
| 89 const NotificationDetails& details); | 89 const NotificationDetails& details); |
| 90 | 90 |
| 91 static const char kDefaultGoogleHomepage[]; | 91 static const char kDefaultGoogleHomepage[]; |
| 92 | 92 |
| 93 NotificationRegistrar registrar_; |
| 93 GURL google_url_; | 94 GURL google_url_; |
| 94 ScopedRunnableMethodFactory<GoogleURLTracker> fetcher_factory_; | 95 ScopedRunnableMethodFactory<GoogleURLTracker> fetcher_factory_; |
| 95 scoped_ptr<URLFetcher> fetcher_; | 96 scoped_ptr<URLFetcher> fetcher_; |
| 96 bool in_startup_sleep_; // True if we're in the five-second "no fetching" | 97 bool in_startup_sleep_; // True if we're in the five-second "no fetching" |
| 97 // period that begins at browser start. | 98 // period that begins at browser start. |
| 98 bool already_fetched_; // True if we've already fetched a URL once this run; | 99 bool already_fetched_; // True if we've already fetched a URL once this run; |
| 99 // we won't fetch again until after a restart. | 100 // we won't fetch again until after a restart. |
| 100 bool need_to_fetch_; // True if a consumer actually wants us to fetch an | 101 bool need_to_fetch_; // True if a consumer actually wants us to fetch an |
| 101 // updated URL. If this is never set, we won't | 102 // updated URL. If this is never set, we won't |
| 102 // bother to fetch anything. | 103 // bother to fetch anything. |
| 103 bool request_context_available_; | 104 bool request_context_available_; |
| 104 // True when the profile has been loaded and the | 105 // True when the profile has been loaded and the |
| 105 // default request context created, so we can | 106 // default request context created, so we can |
| 106 // actually do the fetch with the right data. | 107 // actually do the fetch with the right data. |
| 107 | 108 |
| 108 DISALLOW_COPY_AND_ASSIGN(GoogleURLTracker); | 109 DISALLOW_COPY_AND_ASSIGN(GoogleURLTracker); |
| 109 }; | 110 }; |
| 110 | 111 |
| 111 #endif // CHROME_BROWSER_GOOGLE_URL_TRACKER_H_ | 112 #endif // CHROME_BROWSER_GOOGLE_URL_TRACKER_H_ |
| OLD | NEW |