OLD | NEW |
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 "remoting/host/config_file_watcher.h" | 5 #include "remoting/host/config_file_watcher.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 ConfigFileWatcher::ConfigFileWatcher( | 89 ConfigFileWatcher::ConfigFileWatcher( |
90 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 90 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
91 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, | 91 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
92 const base::FilePath& config_path) | 92 const base::FilePath& config_path) |
93 : impl_(new ConfigFileWatcherImpl(main_task_runner, | 93 : impl_(new ConfigFileWatcherImpl(main_task_runner, |
94 io_task_runner, config_path)) { | 94 io_task_runner, config_path)) { |
95 } | 95 } |
96 | 96 |
97 ConfigFileWatcher::~ConfigFileWatcher() { | 97 ConfigFileWatcher::~ConfigFileWatcher() { |
98 impl_->StopWatching(); | 98 impl_->StopWatching(); |
99 impl_ = NULL; | 99 impl_ = nullptr; |
100 } | 100 } |
101 | 101 |
102 void ConfigFileWatcher::Watch(ConfigWatcher::Delegate* delegate) { | 102 void ConfigFileWatcher::Watch(ConfigWatcher::Delegate* delegate) { |
103 impl_->Watch(delegate); | 103 impl_->Watch(delegate); |
104 } | 104 } |
105 | 105 |
106 ConfigFileWatcherImpl::ConfigFileWatcherImpl( | 106 ConfigFileWatcherImpl::ConfigFileWatcherImpl( |
107 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 107 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
108 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, | 108 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
109 const base::FilePath& config_path) | 109 const base::FilePath& config_path) |
110 : config_path_(config_path), | 110 : config_path_(config_path), |
111 retries_(0), | 111 retries_(0), |
112 delegate_(NULL), | 112 delegate_(nullptr), |
113 main_task_runner_(main_task_runner), | 113 main_task_runner_(main_task_runner), |
114 io_task_runner_(io_task_runner), | 114 io_task_runner_(io_task_runner), |
115 weak_factory_(this) { | 115 weak_factory_(this) { |
116 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 116 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
117 } | 117 } |
118 | 118 |
119 void ConfigFileWatcherImpl::Watch(ConfigWatcher::Delegate* delegate) { | 119 void ConfigFileWatcherImpl::Watch(ConfigWatcher::Delegate* delegate) { |
120 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 120 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
121 DCHECK(!delegate_); | 121 DCHECK(!delegate_); |
122 | 122 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 if (config_ != config) { | 231 if (config_ != config) { |
232 config_ = config; | 232 config_ = config; |
233 main_task_runner_->PostTask( | 233 main_task_runner_->PostTask( |
234 FROM_HERE, | 234 FROM_HERE, |
235 base::Bind(&ConfigFileWatcherImpl::NotifyUpdate, | 235 base::Bind(&ConfigFileWatcherImpl::NotifyUpdate, |
236 weak_factory_.GetWeakPtr(), config_)); | 236 weak_factory_.GetWeakPtr(), config_)); |
237 } | 237 } |
238 } | 238 } |
239 | 239 |
240 } // namespace remoting | 240 } // namespace remoting |
OLD | NEW |