Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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/greasemonkey_master.h" | 5 #include "chrome/browser/greasemonkey_master.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 | 162 |
| 163 | 163 |
| 164 GreasemonkeyMaster::GreasemonkeyMaster(MessageLoop* worker_loop, | 164 GreasemonkeyMaster::GreasemonkeyMaster(MessageLoop* worker_loop, |
| 165 const FilePath& script_dir) | 165 const FilePath& script_dir) |
| 166 : user_script_dir_(new FilePath(script_dir)), | 166 : user_script_dir_(new FilePath(script_dir)), |
| 167 dir_watcher_(new DirectoryWatcher), | 167 dir_watcher_(new DirectoryWatcher), |
| 168 worker_loop_(worker_loop), | 168 worker_loop_(worker_loop), |
| 169 pending_scan_(false) { | 169 pending_scan_(false) { |
| 170 // Watch our scripts directory for modifications. | 170 // Watch our scripts directory for modifications. |
| 171 bool ok = dir_watcher_->Watch(script_dir, this); | 171 bool ok = dir_watcher_->Watch(script_dir, this); |
| 172 DCHECK(ok); | 172 if (ok) { |
|
Evan Martin
2009/01/07 18:47:57
can do "if (dir_watcher_->Watch...)" and eliminate
| |
| 173 | 173 // (Asynchronously) scan for our initial set of scripts. |
| 174 // (Asynchronously) scan for our initial set of scripts. | 174 StartScan(); |
| 175 StartScan(); | 175 } |
| 176 } | 176 } |
| 177 | 177 |
| 178 GreasemonkeyMaster::~GreasemonkeyMaster() { | 178 GreasemonkeyMaster::~GreasemonkeyMaster() { |
| 179 if (script_reloader_) | 179 if (script_reloader_) |
| 180 script_reloader_->DisownMaster(); | 180 script_reloader_->DisownMaster(); |
| 181 } | 181 } |
| 182 | 182 |
| 183 void GreasemonkeyMaster::NewScriptsAvailable(base::SharedMemory* handle) { | 183 void GreasemonkeyMaster::NewScriptsAvailable(base::SharedMemory* handle) { |
| 184 // Ensure handle is deleted or released. | 184 // Ensure handle is deleted or released. |
| 185 scoped_ptr<base::SharedMemory> handle_deleter(handle); | 185 scoped_ptr<base::SharedMemory> handle_deleter(handle); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 211 | 211 |
| 212 StartScan(); | 212 StartScan(); |
| 213 } | 213 } |
| 214 | 214 |
| 215 void GreasemonkeyMaster::StartScan() { | 215 void GreasemonkeyMaster::StartScan() { |
| 216 if (!script_reloader_) | 216 if (!script_reloader_) |
| 217 script_reloader_ = new ScriptReloader(this); | 217 script_reloader_ = new ScriptReloader(this); |
| 218 | 218 |
| 219 script_reloader_->StartScan(worker_loop_, *user_script_dir_); | 219 script_reloader_->StartScan(worker_loop_, *user_script_dir_); |
| 220 } | 220 } |
| OLD | NEW |