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

Side by Side Diff: chrome/browser/upgrade_detector_impl.cc

Issue 271853004: Merge NetworkTimeNotifier to NetworkTimeTracker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 months 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
« no previous file with comments | « chrome/browser/upgrade_detector_impl.h ('k') | chrome/test/base/testing_browser_process.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/upgrade_detector_impl.h" 5 #include "chrome/browser/upgrade_detector_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/build_time.h" 10 #include "base/build_time.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/cpu.h" 12 #include "base/cpu.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/singleton.h" 15 #include "base/memory/singleton.h"
16 #include "base/path_service.h" 16 #include "base/path_service.h"
17 #include "base/prefs/pref_service.h" 17 #include "base/prefs/pref_service.h"
18 #include "base/process/launch.h" 18 #include "base/process/launch.h"
19 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
20 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
21 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
22 #include "base/time/time.h" 22 #include "base/time/time.h"
23 #include "base/version.h" 23 #include "base/version.h"
24 #include "chrome/browser/browser_process.h" 24 #include "chrome/browser/browser_process.h"
25 #include "chrome/browser/google/google_util.h" 25 #include "chrome/browser/google/google_util.h"
26 #include "chrome/browser/network_time/network_time_tracker.h"
26 #include "chrome/common/chrome_switches.h" 27 #include "chrome/common/chrome_switches.h"
27 #include "chrome/common/chrome_version_info.h" 28 #include "chrome/common/chrome_version_info.h"
28 #include "chrome/common/pref_names.h" 29 #include "chrome/common/pref_names.h"
29 #include "content/public/browser/browser_thread.h" 30 #include "content/public/browser/browser_thread.h"
30 #include "ui/base/resource/resource_bundle.h" 31 #include "ui/base/resource/resource_bundle.h"
31 32
32 #if defined(OS_WIN) 33 #if defined(OS_WIN)
33 #include "base/win/win_util.h" 34 #include "base/win/win_util.h"
34 #include "chrome/installer/util/browser_distribution.h" 35 #include "chrome/installer/util/browser_distribution.h"
35 #include "chrome/installer/util/google_update_settings.h" 36 #include "chrome/installer/util/google_update_settings.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 // Always enable upgrade notifications regardless of branding. 240 // Always enable upgrade notifications regardless of branding.
240 #else 241 #else
241 return; 242 return;
242 #endif 243 #endif
243 // Check whether the build is an unstable channel before starting the timer. 244 // Check whether the build is an unstable channel before starting the timer.
244 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 245 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
245 base::Bind(&CheckForUnstableChannel, 246 base::Bind(&CheckForUnstableChannel,
246 start_upgrade_check_timer_task, 247 start_upgrade_check_timer_task,
247 &is_unstable_channel_)); 248 &is_unstable_channel_));
248 #endif 249 #endif
249 // Start tracking network time updates.
250 network_time_tracker_.Start();
251 } 250 }
252 251
253 UpgradeDetectorImpl::~UpgradeDetectorImpl() { 252 UpgradeDetectorImpl::~UpgradeDetectorImpl() {
254 } 253 }
255 254
256 // Static 255 // Static
257 // This task checks the currently running version of Chrome against the 256 // This task checks the currently running version of Chrome against the
258 // installed version. If the installed version is newer, it calls back 257 // installed version. If the installed version is newer, it calls back
259 // UpgradeDetectorImpl::UpgradeDetected using a weak pointer so that it can 258 // UpgradeDetectorImpl::UpgradeDetected using a weak pointer so that it can
260 // be interrupted from the UI thread. 259 // be interrupted from the UI thread.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 370
372 // On Windows, we don't want to warn about outdated installs when the 371 // On Windows, we don't want to warn about outdated installs when the
373 // machine doesn't support SSE2, it's been deprecated starting with M35. 372 // machine doesn't support SSE2, it's been deprecated starting with M35.
374 if (!base::CPU().has_sse2()) 373 if (!base::CPU().has_sse2())
375 return false; 374 return false;
376 #endif 375 #endif
377 } 376 }
378 377
379 base::Time network_time; 378 base::Time network_time;
380 base::TimeDelta uncertainty; 379 base::TimeDelta uncertainty;
381 if (!network_time_tracker_.GetNetworkTime(base::TimeTicks::Now(), 380 if (!g_browser_process->network_time_tracker()->GetNetworkTime(
382 &network_time, 381 base::TimeTicks::Now(), &network_time, &uncertainty)) {
383 &uncertainty)) {
384 // When network time has not been initialized yet, simply rely on the 382 // When network time has not been initialized yet, simply rely on the
385 // machine's current time. 383 // machine's current time.
386 network_time = base::Time::Now(); 384 network_time = base::Time::Now();
387 } 385 }
388 386
389 if (network_time.is_null() || build_date_.is_null() || 387 if (network_time.is_null() || build_date_.is_null() ||
390 build_date_ > network_time) { 388 build_date_ > network_time) {
391 NOTREACHED(); 389 NOTREACHED();
392 return false; 390 return false;
393 } 391 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 478
481 // static 479 // static
482 UpgradeDetectorImpl* UpgradeDetectorImpl::GetInstance() { 480 UpgradeDetectorImpl* UpgradeDetectorImpl::GetInstance() {
483 return Singleton<UpgradeDetectorImpl>::get(); 481 return Singleton<UpgradeDetectorImpl>::get();
484 } 482 }
485 483
486 // static 484 // static
487 UpgradeDetector* UpgradeDetector::GetInstance() { 485 UpgradeDetector* UpgradeDetector::GetInstance() {
488 return UpgradeDetectorImpl::GetInstance(); 486 return UpgradeDetectorImpl::GetInstance();
489 } 487 }
OLDNEW
« no previous file with comments | « chrome/browser/upgrade_detector_impl.h ('k') | chrome/test/base/testing_browser_process.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698