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

Side by Side Diff: chrome/browser/extensions/user_script_master.cc

Issue 115229: Add support for almost-recursive watches in Linux DirectoryWatcher (Closed)
Patch Set: fix NULL file_thread scenario Created 11 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
« no previous file with comments | « base/file_util_posix.cc ('k') | no next file » | 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) 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/extensions/user_script_master.h" 5 #include "chrome/browser/extensions/user_script_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"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/pickle.h" 12 #include "base/pickle.h"
13 #include "base/stl_util-inl.h" 13 #include "base/stl_util-inl.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "base/thread.h"
16 #include "chrome/browser/browser_process.h"
15 #include "chrome/common/notification_service.h" 17 #include "chrome/common/notification_service.h"
16 #include "chrome/common/url_constants.h" 18 #include "chrome/common/url_constants.h"
17 #include "net/base/net_util.h" 19 #include "net/base/net_util.h"
18 20
19 21
20 // Helper function to parse greasesmonkey headers 22 // Helper function to parse greasesmonkey headers
21 static bool GetDeclarationValue(const StringPiece& line, 23 static bool GetDeclarationValue(const StringPiece& line,
22 const StringPiece& prefix, 24 const StringPiece& prefix,
23 std::string* value) { 25 std::string* value) {
24 if (!line.starts_with(prefix)) 26 if (!line.starts_with(prefix))
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 if (script_reloader_) 263 if (script_reloader_)
262 script_reloader_->DisownMaster(); 264 script_reloader_->DisownMaster();
263 265
264 // TODO(aa): Enable this when DirectoryWatcher is implemented for linux. 266 // TODO(aa): Enable this when DirectoryWatcher is implemented for linux.
265 #if defined(OS_WIN) || defined(OS_MACOSX) 267 #if defined(OS_WIN) || defined(OS_MACOSX)
266 STLDeleteElements(&dir_watchers_); 268 STLDeleteElements(&dir_watchers_);
267 #endif 269 #endif
268 } 270 }
269 271
270 void UserScriptMaster::AddWatchedPath(const FilePath& path) { 272 void UserScriptMaster::AddWatchedPath(const FilePath& path) {
271 // TODO(aa): Enable this when DirectoryWatcher is implemented for linux. 273 // TODO(aa): Enable this when DirectoryWatcher is implemented for linux.
Evan Martin 2009/05/14 17:48:28 I guess this TODO can be fixed now! Maybe in a di
272 #if defined(OS_WIN) || defined(OS_MACOSX) 274 #if defined(OS_WIN) || defined(OS_MACOSX)
273 DirectoryWatcher* watcher = new DirectoryWatcher(); 275 DirectoryWatcher* watcher = new DirectoryWatcher();
274 watcher->Watch(path, this, true); 276 base::Thread* file_thread = g_browser_process->file_thread();
277 watcher->Watch(path, this, file_thread ? file_thread->message_loop() : NULL,
278 true);
275 dir_watchers_.push_back(watcher); 279 dir_watchers_.push_back(watcher);
276 #endif 280 #endif
277 } 281 }
278 282
279 void UserScriptMaster::NewScriptsAvailable(base::SharedMemory* handle) { 283 void UserScriptMaster::NewScriptsAvailable(base::SharedMemory* handle) {
280 // Ensure handle is deleted or released. 284 // Ensure handle is deleted or released.
281 scoped_ptr<base::SharedMemory> handle_deleter(handle); 285 scoped_ptr<base::SharedMemory> handle_deleter(handle);
282 286
283 if (pending_scan_) { 287 if (pending_scan_) {
284 // While we were scanning, there were further changes. Don't bother 288 // While we were scanning, there were further changes. Don't bother
(...skipping 23 matching lines...) Expand all
308 312
309 StartScan(); 313 StartScan();
310 } 314 }
311 315
312 void UserScriptMaster::StartScan() { 316 void UserScriptMaster::StartScan() {
313 if (!script_reloader_) 317 if (!script_reloader_)
314 script_reloader_ = new ScriptReloader(this); 318 script_reloader_ = new ScriptReloader(this);
315 319
316 script_reloader_->StartScan(worker_loop_, user_script_dir_, lone_scripts_); 320 script_reloader_->StartScan(worker_loop_, user_script_dir_, lone_scripts_);
317 } 321 }
OLDNEW
« no previous file with comments | « base/file_util_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698