Skip to content

Commit

Permalink
Modernize some TimeZoneMonitor code.
Browse files Browse the repository at this point in the history
- Use std::make_unique() and "= default" in TimeZoneMonitorWin.
- Change a TimeZoneMonitorWin member from std::unique_ptr<T> to T.
- Get rid of DISALLOW_COPY_AND_ASSIGN() in TimeZoneMonitor.

Change-Id: I9dea9a1873cf8a04ad77ca3953aeeada0c74e8e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3119686
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Colin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#916522}
  • Loading branch information
leizleiz authored and Chromium LUCI CQ committed Aug 30, 2021
1 parent a04da56 commit cc8763d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions services/device/time_zone_monitor/time_zone_monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <memory>
#include <string>

#include "base/macros.h"
#include "base/strings/string_piece_forward.h"
#include "base/threading/thread_checker.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
Expand Down Expand Up @@ -56,6 +55,8 @@ class TimeZoneMonitor : public device::mojom::TimeZoneMonitor {
static std::unique_ptr<TimeZoneMonitor> Create(
scoped_refptr<base::SequencedTaskRunner> file_task_runner);

TimeZoneMonitor(const TimeZoneMonitor&) = delete;
TimeZoneMonitor& operator=(const TimeZoneMonitor&) = delete;
~TimeZoneMonitor() override;

void Bind(mojo::PendingReceiver<device::mojom::TimeZoneMonitor> receiver);
Expand Down Expand Up @@ -88,7 +89,6 @@ class TimeZoneMonitor : public device::mojom::TimeZoneMonitor {

mojo::ReceiverSet<device::mojom::TimeZoneMonitor> receivers_;
mojo::RemoteSet<device::mojom::TimeZoneMonitorClient> clients_;
DISALLOW_COPY_AND_ASSIGN(TimeZoneMonitor);
};

} // namespace device
Expand Down
10 changes: 5 additions & 5 deletions services/device/time_zone_monitor/time_zone_monitor_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ class TimeZoneMonitorWin : public TimeZoneMonitor {
public:
TimeZoneMonitorWin()
: TimeZoneMonitor(),
singleton_hwnd_observer_(new gfx::SingletonHwndObserver(
singleton_hwnd_observer_(
base::BindRepeating(&TimeZoneMonitorWin::OnWndProc,
base::Unretained(this)))),
base::Unretained(this))),
current_platform_timezone_(GetPlatformTimeZone()) {}
TimeZoneMonitorWin(const TimeZoneMonitorWin&) = delete;
TimeZoneMonitorWin& operator=(const TimeZoneMonitorWin&) = delete;

~TimeZoneMonitorWin() override {}
~TimeZoneMonitorWin() override = default;

private:
void OnWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) {
Expand Down Expand Up @@ -85,7 +85,7 @@ class TimeZoneMonitorWin : public TimeZoneMonitor {
pending_update_notification_tasks_ = false;
}

std::unique_ptr<gfx::SingletonHwndObserver> singleton_hwnd_observer_;
gfx::SingletonHwndObserver singleton_hwnd_observer_;
bool pending_update_notification_tasks_ = false;
std::string current_platform_timezone_;
base::WeakPtrFactory<TimeZoneMonitorWin> weak_ptr_factory_{this};
Expand All @@ -94,7 +94,7 @@ class TimeZoneMonitorWin : public TimeZoneMonitor {
// static
std::unique_ptr<TimeZoneMonitor> TimeZoneMonitor::Create(
scoped_refptr<base::SequencedTaskRunner> file_task_runner) {
return std::unique_ptr<TimeZoneMonitor>(new TimeZoneMonitorWin());
return std::make_unique<TimeZoneMonitorWin>();
}

} // namespace device

0 comments on commit cc8763d

Please sign in to comment.