OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/net/predictor_api.h" | 5 #include "chrome/browser/net/predictor_api.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
11 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
12 #include "base/stl_util-inl.h" | 12 #include "base/stl_util-inl.h" |
13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
14 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
15 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
18 #include "chrome/browser/io_thread.h" | 18 #include "chrome/browser/io_thread.h" |
19 #include "chrome/browser/net/preconnect.h" | 19 #include "chrome/browser/net/preconnect.h" |
20 #include "chrome/browser/net/referrer.h" | 20 #include "chrome/browser/net/referrer.h" |
21 #include "chrome/browser/net/url_info.h" | 21 #include "chrome/browser/net/url_info.h" |
22 #include "chrome/browser/prefs/browser_prefs.h" | 22 #include "chrome/browser/prefs/browser_prefs.h" |
23 #include "chrome/browser/prefs/pref_service.h" | 23 #include "chrome/browser/prefs/pref_service.h" |
24 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 24 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
25 #include "chrome/browser/prefs/session_startup_pref.h" | 25 #include "chrome/browser/prefs/session_startup_pref.h" |
26 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
27 #include "chrome/browser/ui/browser.h" | 27 #include "chrome/browser/ui/browser.h" |
| 28 #include "chrome/common/chrome_notification_types.h" |
28 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
29 #include "content/browser/browser_thread.h" | 30 #include "content/browser/browser_thread.h" |
30 #include "content/common/notification_registrar.h" | 31 #include "content/common/notification_registrar.h" |
31 #include "content/common/notification_service.h" | 32 #include "content/common/notification_service.h" |
32 #include "net/base/host_resolver.h" | 33 #include "net/base/host_resolver.h" |
33 #include "net/base/host_resolver_impl.h" | 34 #include "net/base/host_resolver_impl.h" |
34 | 35 |
35 using base::Time; | 36 using base::Time; |
36 using base::TimeDelta; | 37 using base::TimeDelta; |
37 | 38 |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 | 298 |
298 //------------------------------------------------------------------------------ | 299 //------------------------------------------------------------------------------ |
299 // Support observer to detect opening and closing of OffTheRecord windows. | 300 // Support observer to detect opening and closing of OffTheRecord windows. |
300 // This object lives on the UI thread. | 301 // This object lives on the UI thread. |
301 | 302 |
302 class OffTheRecordObserver : public NotificationObserver { | 303 class OffTheRecordObserver : public NotificationObserver { |
303 public: | 304 public: |
304 void Register() { | 305 void Register() { |
305 // TODO(pkasting): This test should not be necessary. See crbug.com/12475. | 306 // TODO(pkasting): This test should not be necessary. See crbug.com/12475. |
306 if (registrar_.IsEmpty()) { | 307 if (registrar_.IsEmpty()) { |
307 registrar_.Add(this, NotificationType::BROWSER_CLOSED, | 308 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSED, |
308 NotificationService::AllSources()); | 309 NotificationService::AllSources()); |
309 registrar_.Add(this, NotificationType::BROWSER_OPENED, | 310 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_OPENED, |
310 NotificationService::AllSources()); | 311 NotificationService::AllSources()); |
311 } | 312 } |
312 } | 313 } |
313 | 314 |
314 void Observe(NotificationType type, const NotificationSource& source, | 315 void Observe(int type, const NotificationSource& source, |
315 const NotificationDetails& details) { | 316 const NotificationDetails& details) { |
316 switch (type.value) { | 317 switch (type) { |
317 case NotificationType::BROWSER_OPENED: | 318 case chrome::NOTIFICATION_BROWSER_OPENED: |
318 if (!Source<Browser>(source)->profile()->IsOffTheRecord()) | 319 if (!Source<Browser>(source)->profile()->IsOffTheRecord()) |
319 break; | 320 break; |
320 ++count_off_the_record_windows_; | 321 ++count_off_the_record_windows_; |
321 OnTheRecord(false); | 322 OnTheRecord(false); |
322 break; | 323 break; |
323 | 324 |
324 case NotificationType::BROWSER_CLOSED: | 325 case chrome::NOTIFICATION_BROWSER_CLOSED: |
325 if (!Source<Browser>(source)->profile()->IsOffTheRecord()) | 326 if (!Source<Browser>(source)->profile()->IsOffTheRecord()) |
326 break; // Ignore ordinary windows. | 327 break; // Ignore ordinary windows. |
327 DCHECK_LT(0, count_off_the_record_windows_); | 328 DCHECK_LT(0, count_off_the_record_windows_); |
328 if (0 >= count_off_the_record_windows_) // Defensive coding. | 329 if (0 >= count_off_the_record_windows_) // Defensive coding. |
329 break; | 330 break; |
330 if (--count_off_the_record_windows_) | 331 if (--count_off_the_record_windows_) |
331 break; // Still some windows are incognito. | 332 break; // Still some windows are incognito. |
332 OnTheRecord(true); | 333 OnTheRecord(true); |
333 break; | 334 break; |
334 | 335 |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 DCHECK(!g_predictor); | 641 DCHECK(!g_predictor); |
641 InitNetworkPredictor(max_queueing_delay, max_parallel_resolves, user_prefs, | 642 InitNetworkPredictor(max_queueing_delay, max_parallel_resolves, user_prefs, |
642 local_state, preconnect_enabled); | 643 local_state, preconnect_enabled); |
643 } | 644 } |
644 } | 645 } |
645 | 646 |
646 PredictorInit::~PredictorInit() { | 647 PredictorInit::~PredictorInit() { |
647 } | 648 } |
648 | 649 |
649 } // namespace chrome_browser_net | 650 } // namespace chrome_browser_net |
OLD | NEW |