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

Side by Side Diff: content/browser/time_zone_monitor.cc

Issue 1874893002: Convert //content/browser from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « content/browser/time_zone_monitor.h ('k') | content/browser/time_zone_monitor_android.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/time_zone_monitor.h" 5 #include "content/browser/time_zone_monitor.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "content/public/browser/render_process_host.h" 10 #include "content/public/browser/render_process_host.h"
11 #include "third_party/icu/source/common/unicode/unistr.h" 11 #include "third_party/icu/source/common/unicode/unistr.h"
12 #include "third_party/icu/source/i18n/unicode/timezone.h" 12 #include "third_party/icu/source/i18n/unicode/timezone.h"
13 13
14 namespace content { 14 namespace content {
15 15
16 TimeZoneMonitor::TimeZoneMonitor() { 16 TimeZoneMonitor::TimeZoneMonitor() {
17 DCHECK_CURRENTLY_ON(BrowserThread::UI); 17 DCHECK_CURRENTLY_ON(BrowserThread::UI);
18 } 18 }
19 19
20 TimeZoneMonitor::~TimeZoneMonitor() { 20 TimeZoneMonitor::~TimeZoneMonitor() {
21 DCHECK_CURRENTLY_ON(BrowserThread::UI); 21 DCHECK_CURRENTLY_ON(BrowserThread::UI);
22 } 22 }
23 23
24 void TimeZoneMonitor::NotifyRenderers() { 24 void TimeZoneMonitor::NotifyRenderers() {
25 DCHECK_CURRENTLY_ON(BrowserThread::UI); 25 DCHECK_CURRENTLY_ON(BrowserThread::UI);
26 #if defined(OS_CHROMEOS) 26 #if defined(OS_CHROMEOS)
27 // On CrOS, ICU's default tz is already set to a new zone. No 27 // On CrOS, ICU's default tz is already set to a new zone. No
28 // need to redetect it with detectHostTimeZone(). 28 // need to redetect it with detectHostTimeZone().
29 scoped_ptr<icu::TimeZone> new_zone(icu::TimeZone::createDefault()); 29 std::unique_ptr<icu::TimeZone> new_zone(icu::TimeZone::createDefault());
30 #else 30 #else
31 icu::TimeZone* new_zone = icu::TimeZone::detectHostTimeZone(); 31 icu::TimeZone* new_zone = icu::TimeZone::detectHostTimeZone();
32 #if defined(OS_LINUX) 32 #if defined(OS_LINUX)
33 // We get here multiple times on Linux per a single tz change, but 33 // We get here multiple times on Linux per a single tz change, but
34 // want to update the ICU default zone and notify renderer only once. 34 // want to update the ICU default zone and notify renderer only once.
35 scoped_ptr<icu::TimeZone> current_zone(icu::TimeZone::createDefault()); 35 std::unique_ptr<icu::TimeZone> current_zone(icu::TimeZone::createDefault());
36 if (*current_zone == *new_zone) { 36 if (*current_zone == *new_zone) {
37 VLOG(1) << "timezone already updated"; 37 VLOG(1) << "timezone already updated";
38 delete new_zone; 38 delete new_zone;
39 return; 39 return;
40 } 40 }
41 #endif 41 #endif
42 icu::TimeZone::adoptDefault(new_zone); 42 icu::TimeZone::adoptDefault(new_zone);
43 #endif 43 #endif
44 icu::UnicodeString zone_id; 44 icu::UnicodeString zone_id;
45 std::string zone_id_str; 45 std::string zone_id_str;
46 new_zone->getID(zone_id).toUTF8String(zone_id_str); 46 new_zone->getID(zone_id).toUTF8String(zone_id_str);
47 VLOG(1) << "timezone reset to " << zone_id_str; 47 VLOG(1) << "timezone reset to " << zone_id_str;
48 for (RenderProcessHost::iterator iterator = 48 for (RenderProcessHost::iterator iterator =
49 RenderProcessHost::AllHostsIterator(); 49 RenderProcessHost::AllHostsIterator();
50 !iterator.IsAtEnd(); 50 !iterator.IsAtEnd();
51 iterator.Advance()) { 51 iterator.Advance()) {
52 iterator.GetCurrentValue()->NotifyTimezoneChange(zone_id_str); 52 iterator.GetCurrentValue()->NotifyTimezoneChange(zone_id_str);
53 } 53 }
54 } 54 }
55 55
56 } // namespace content 56 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/time_zone_monitor.h ('k') | content/browser/time_zone_monitor_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698