Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: chrome/browser/net/predictor_api.cc

Issue 5711001: Add a new GetInstance() method for remaining files with singleton classes under chrome/browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
11 #include "base/singleton.h" 11 #include "base/lazy_instance.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/thread.h" 14 #include "base/thread.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "base/waitable_event.h" 16 #include "base/waitable_event.h"
17 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/browser_thread.h" 18 #include "chrome/browser/browser_thread.h"
19 #include "chrome/browser/io_thread.h" 19 #include "chrome/browser/io_thread.h"
20 #include "chrome/browser/net/preconnect.h" 20 #include "chrome/browser/net/preconnect.h"
21 #include "chrome/browser/net/referrer.h" 21 #include "chrome/browser/net/referrer.h"
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 break; // Still some windows are incognito. 323 break; // Still some windows are incognito.
324 OnTheRecord(true); 324 OnTheRecord(true);
325 break; 325 break;
326 326
327 default: 327 default:
328 break; 328 break;
329 } 329 }
330 } 330 }
331 331
332 private: 332 private:
333 friend struct DefaultSingletonTraits<OffTheRecordObserver>; 333 friend struct base::DefaultLazyInstanceTraits<OffTheRecordObserver>;
334
334 OffTheRecordObserver() : count_off_the_record_windows_(0) {} 335 OffTheRecordObserver() : count_off_the_record_windows_(0) {}
335 ~OffTheRecordObserver() {} 336 ~OffTheRecordObserver() {}
336 337
337 NotificationRegistrar registrar_; 338 NotificationRegistrar registrar_;
338 int count_off_the_record_windows_; 339 int count_off_the_record_windows_;
339 340
340 DISALLOW_COPY_AND_ASSIGN(OffTheRecordObserver); 341 DISALLOW_COPY_AND_ASSIGN(OffTheRecordObserver);
341 }; 342 };
342 343
344 static base::LazyInstance<OffTheRecordObserver> g_off_the_record_observer(
345 base::LINKER_INITIALIZED);
346
343 //------------------------------------------------------------------------------ 347 //------------------------------------------------------------------------------
344 // This section supports the about:dns page. 348 // This section supports the about:dns page.
345 //------------------------------------------------------------------------------ 349 //------------------------------------------------------------------------------
346 350
347 // Provide global support for the about:dns page. 351 // Provide global support for the about:dns page.
348 void PredictorGetHtmlInfo(std::string* output) { 352 void PredictorGetHtmlInfo(std::string* output) {
349 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 353 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
350 354
351 output->append("<html><head><title>About DNS</title>" 355 output->append("<html><head><title>About DNS</title>"
352 // We'd like the following no-cache... but it doesn't work. 356 // We'd like the following no-cache... but it doesn't work.
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 int max_4_concurrent_prefetch = trial_->AppendGroup( 573 int max_4_concurrent_prefetch = trial_->AppendGroup(
570 "max_4 concurrent_prefetch", kProbabilityPerGroup); 574 "max_4 concurrent_prefetch", kProbabilityPerGroup);
571 int max_6_concurrent_prefetch = trial_->AppendGroup( 575 int max_6_concurrent_prefetch = trial_->AppendGroup(
572 "max_6 concurrent_prefetch", kProbabilityPerGroup); 576 "max_6 concurrent_prefetch", kProbabilityPerGroup);
573 577
574 trial_->AppendGroup("default_enabled_prefetch", 578 trial_->AppendGroup("default_enabled_prefetch",
575 base::FieldTrial::kAllRemainingProbability); 579 base::FieldTrial::kAllRemainingProbability);
576 580
577 // We will register the incognito observer regardless of whether prefetching 581 // We will register the incognito observer regardless of whether prefetching
578 // is enabled, as it is also used to clear the host cache. 582 // is enabled, as it is also used to clear the host cache.
579 Singleton<OffTheRecordObserver>::get()->Register(); 583 g_off_the_record_observer.Get().Register();
580 584
581 if (trial_->group() != disabled_prefetch) { 585 if (trial_->group() != disabled_prefetch) {
582 // Initialize the DNS prefetch system. 586 // Initialize the DNS prefetch system.
583 size_t max_parallel_resolves = kMaxSpeculativeParallelResolves; 587 size_t max_parallel_resolves = kMaxSpeculativeParallelResolves;
584 int max_queueing_delay_ms = kMaxSpeculativeResolveQueueDelayMs; 588 int max_queueing_delay_ms = kMaxSpeculativeResolveQueueDelayMs;
585 589
586 if (trial_->group() == max_2_concurrent_prefetch) 590 if (trial_->group() == max_2_concurrent_prefetch)
587 max_parallel_resolves = 2; 591 max_parallel_resolves = 2;
588 else if (trial_->group() == max_4_concurrent_prefetch) 592 else if (trial_->group() == max_4_concurrent_prefetch)
589 max_parallel_resolves = 4; 593 max_parallel_resolves = 4;
(...skipping 20 matching lines...) Expand all
610 DCHECK(!g_predictor); 614 DCHECK(!g_predictor);
611 InitNetworkPredictor(max_queueing_delay, max_parallel_resolves, user_prefs, 615 InitNetworkPredictor(max_queueing_delay, max_parallel_resolves, user_prefs,
612 local_state, preconnect_enabled); 616 local_state, preconnect_enabled);
613 } 617 }
614 } 618 }
615 619
616 PredictorInit::~PredictorInit() { 620 PredictorInit::~PredictorInit() {
617 } 621 }
618 622
619 } // namespace chrome_browser_net 623 } // namespace chrome_browser_net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698