diff options
-rw-r--r-- | base/base.gypi | 13 | ||||
-rw-r--r-- | base/files/OWNERS (renamed from content/common/file_path_watcher/OWNERS) | 1 | ||||
-rw-r--r-- | base/files/file_path_watcher.cc (renamed from content/common/file_path_watcher/file_path_watcher.cc) | 7 | ||||
-rw-r--r-- | base/files/file_path_watcher.h (renamed from content/common/file_path_watcher/file_path_watcher.h) | 12 | ||||
-rw-r--r-- | base/files/file_path_watcher_browsertest.cc (renamed from content/common/file_path_watcher/file_path_watcher_browsertest.cc) | 8 | ||||
-rw-r--r-- | base/files/file_path_watcher_linux.cc (renamed from content/common/file_path_watcher/file_path_watcher_inotify.cc) | 8 | ||||
-rw-r--r-- | base/files/file_path_watcher_mac.cc (renamed from content/common/file_path_watcher/file_path_watcher_mac.cc) | 8 | ||||
-rw-r--r-- | base/files/file_path_watcher_stub.cc (renamed from content/common/file_path_watcher/file_path_watcher_stub.cc) | 12 | ||||
-rw-r--r-- | base/files/file_path_watcher_win.cc (renamed from content/common/file_path_watcher/file_path_watcher_win.cc) | 9 | ||||
-rw-r--r-- | chrome/browser/policy/file_based_policy_loader.cc | 2 | ||||
-rw-r--r-- | chrome/browser/policy/file_based_policy_loader.h | 4 | ||||
-rw-r--r-- | chrome/browser/user_style_sheet_watcher.cc | 2 | ||||
-rw-r--r-- | chrome/browser/user_style_sheet_watcher.h | 4 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 4 | ||||
-rw-r--r-- | chrome/common/service_process_util_mac.mm | 2 | ||||
-rw-r--r-- | chrome/common/service_process_util_posix.h | 4 | ||||
-rw-r--r-- | content/browser/plugin_service.cc | 6 | ||||
-rw-r--r-- | content/browser/plugin_service.h | 8 | ||||
-rw-r--r-- | content/content_common.gypi | 15 |
19 files changed, 93 insertions, 36 deletions
diff --git a/base/base.gypi b/base/base.gypi index 44fa935..4f409ab 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -88,6 +88,11 @@ 'file_version_info_mac.mm', 'file_version_info_win.cc', 'file_version_info_win.h', + 'files/file_path_watcher.cc', + 'files/file_path_watcher.h', + 'files/file_path_watcher_linux.cc', + 'files/file_path_watcher_mac.cc', + 'files/file_path_watcher_win.cc', 'fix_wp64.h', 'float_util.h', 'foundation_utils_mac.h', @@ -401,6 +406,14 @@ 'debug/trace_event.cc', ], },], + ['OS=="freebsd" or OS=="openbsd"', { + 'sources!': [ + 'base/files/file_path_watcher_linux.cc', + ], + 'sources': [ + 'base/files/file_path_watcher_stub.cc', + ], + }], ], }], ], diff --git a/content/common/file_path_watcher/OWNERS b/base/files/OWNERS index e83a27d..ef0b156 100644 --- a/content/common/file_path_watcher/OWNERS +++ b/base/files/OWNERS @@ -1,2 +1,3 @@ +# for file_path_watcher* mnissler@chromium.org dmaclach@chromium.org diff --git a/content/common/file_path_watcher/file_path_watcher.cc b/base/files/file_path_watcher.cc index 41f3e2b..7ce64ac 100644 --- a/content/common/file_path_watcher/file_path_watcher.cc +++ b/base/files/file_path_watcher.cc @@ -5,11 +5,14 @@ // Cross platform methods for FilePathWatcher. See the various platform // specific implementation files, too. -#include "content/common/file_path_watcher/file_path_watcher.h" +#include "base/files/file_path_watcher.h" #include "base/logging.h" #include "base/message_loop.h" +namespace base { +namespace files { + FilePathWatcher::~FilePathWatcher() { impl_->Cancel(); } @@ -26,3 +29,5 @@ FilePathWatcher::PlatformDelegate::~PlatformDelegate() { DCHECK(is_cancelled()); } +} // namespace files +} // namespace base diff --git a/content/common/file_path_watcher/file_path_watcher.h b/base/files/file_path_watcher.h index 094b04f..2cf95c6 100644 --- a/content/common/file_path_watcher/file_path_watcher.h +++ b/base/files/file_path_watcher.h @@ -4,8 +4,8 @@ // This module provides a way to monitor a file or directory for changes. -#ifndef CONTENT_COMMON_FILE_PATH_WATCHER_FILE_PATH_WATCHER_H_ -#define CONTENT_COMMON_FILE_PATH_WATCHER_FILE_PATH_WATCHER_H_ +#ifndef BASE_FILES_FILE_PATH_WATCHER_H_ +#define BASE_FILES_FILE_PATH_WATCHER_H_ #pragma once #include "base/basictypes.h" @@ -13,6 +13,9 @@ #include "base/memory/ref_counted.h" #include "base/message_loop_proxy.h" +namespace base { +namespace files { + // This class lets you register interest in changes on a FilePath. // The delegate will get called whenever the file or directory referenced by the // FilePath is changed, including created or deleted. Due to limitations in the @@ -119,4 +122,7 @@ class FilePathWatcher { DISALLOW_COPY_AND_ASSIGN(FilePathWatcher); }; -#endif // CONTENT_COMMON_FILE_PATH_WATCHER_FILE_PATH_WATCHER_H_ +} // namespace files +} // namespace base + +#endif // BASE_FILES_FILE_PATH_WATCHER_H_ diff --git a/content/common/file_path_watcher/file_path_watcher_browsertest.cc b/base/files/file_path_watcher_browsertest.cc index b847ca9..d623c90 100644 --- a/content/common/file_path_watcher/file_path_watcher_browsertest.cc +++ b/base/files/file_path_watcher_browsertest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/common/file_path_watcher/file_path_watcher.h" +#include "base/files/file_path_watcher.h" #include <set> @@ -28,6 +28,9 @@ #include "base/threading/thread.h" #include "testing/gtest/include/gtest/gtest.h" +namespace base { +namespace files { + namespace { class TestDelegate; @@ -614,3 +617,6 @@ TEST_F(FilePathWatcherTest, DirAttributesChanged) { #endif // OS_MACOSX } // namespace + +} // namespace files +} // namespace base diff --git a/content/common/file_path_watcher/file_path_watcher_inotify.cc b/base/files/file_path_watcher_linux.cc index f91756f..0fb10e4 100644 --- a/content/common/file_path_watcher/file_path_watcher_inotify.cc +++ b/base/files/file_path_watcher_linux.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/common/file_path_watcher/file_path_watcher.h" +#include "base/files/file_path_watcher.h" #include <errno.h> #include <string.h> @@ -29,6 +29,9 @@ #include "base/task.h" #include "base/threading/thread.h" +namespace base { +namespace files { + namespace { class FilePathWatcherImpl; @@ -454,3 +457,6 @@ bool FilePathWatcherImpl::UpdateWatches() { FilePathWatcher::FilePathWatcher() { impl_ = new FilePathWatcherImpl(); } + +} // namespace files +} // namespace base diff --git a/content/common/file_path_watcher/file_path_watcher_mac.cc b/base/files/file_path_watcher_mac.cc index eb72b94..7b61f76 100644 --- a/content/common/file_path_watcher/file_path_watcher_mac.cc +++ b/base/files/file_path_watcher_mac.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/common/file_path_watcher/file_path_watcher.h" +#include "base/files/file_path_watcher.h" #include <fcntl.h> #include <sys/event.h> @@ -15,6 +15,9 @@ #include "base/message_loop_proxy.h" #include "base/stringprintf.h" +namespace base { +namespace files { + namespace { // Mac-specific file watcher implementation based on kqueue. @@ -485,3 +488,6 @@ void FilePathWatcherImpl::CancelOnMessageLoopThread() { FilePathWatcher::FilePathWatcher() { impl_ = new FilePathWatcherImpl(); } + +} // namespace files +} // namespace base diff --git a/content/common/file_path_watcher/file_path_watcher_stub.cc b/base/files/file_path_watcher_stub.cc index 42b6ec6..a693dc7 100644 --- a/content/common/file_path_watcher/file_path_watcher_stub.cc +++ b/base/files/file_path_watcher_stub.cc @@ -5,7 +5,12 @@ // This file exists for Unix systems which don't have the inotify headers, and // thus cannot build file_watcher_inotify.cc -#include "chrome/common/file_path_watcher/file_path_watcher.h" +#include "base/files/file_path_watcher.h" + +namespace base { +namespace files { + +namespace { class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate { public: @@ -16,6 +21,11 @@ class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate { } }; +} // namespace + FilePathWatcher::FilePathWatcher() { impl_ = new FilePathWatcherImpl(); } + +} // namespace files +} // namespace base diff --git a/content/common/file_path_watcher/file_path_watcher_win.cc b/base/files/file_path_watcher_win.cc index bf24e18..eedcf22 100644 --- a/content/common/file_path_watcher/file_path_watcher_win.cc +++ b/base/files/file_path_watcher_win.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/common/file_path_watcher/file_path_watcher.h" +#include "base/files/file_path_watcher.h" #include "base/file_path.h" #include "base/file_util.h" @@ -12,6 +12,9 @@ #include "base/time.h" #include "base/win/object_watcher.h" +namespace base { +namespace files { + namespace { class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate, @@ -202,6 +205,7 @@ bool FilePathWatcherImpl::SetupWatchHandle(const FilePath& dir, error_code != ERROR_ACCESS_DENIED && error_code != ERROR_SHARING_VIOLATION && error_code != ERROR_DIRECTORY) { + using ::operator<<; // Pick the right operator<< below. PLOG(ERROR) << "FindFirstChangeNotification failed for " << dir.value(); return false; @@ -272,3 +276,6 @@ void FilePathWatcherImpl::DestroyWatch() { FilePathWatcher::FilePathWatcher() { impl_ = new FilePathWatcherImpl(); } + +} // namespace files +} // namespace base diff --git a/chrome/browser/policy/file_based_policy_loader.cc b/chrome/browser/policy/file_based_policy_loader.cc index a127a71..e97d065 100644 --- a/chrome/browser/policy/file_based_policy_loader.cc +++ b/chrome/browser/policy/file_based_policy_loader.cc @@ -7,6 +7,8 @@ #include "base/compiler_specific.h" #include "content/browser/browser_thread.h" +using ::base::files::FilePathWatcher; + namespace { // Amount of time we wait for the files on disk to settle before trying to load diff --git a/chrome/browser/policy/file_based_policy_loader.h b/chrome/browser/policy/file_based_policy_loader.h index d7dedcc..4a2919c 100644 --- a/chrome/browser/policy/file_based_policy_loader.h +++ b/chrome/browser/policy/file_based_policy_loader.h @@ -6,9 +6,9 @@ #define CHROME_BROWSER_POLICY_FILE_BASED_POLICY_LOADER_H_ #pragma once +#include "base/files/file_path_watcher.h" #include "chrome/browser/policy/asynchronous_policy_loader.h" #include "chrome/browser/policy/file_based_policy_provider.h" -#include "content/common/file_path_watcher/file_path_watcher.h" namespace policy { @@ -56,7 +56,7 @@ class FileBasedPolicyLoader : public AsynchronousPolicyLoader { // it possible to destroy the watcher before the loader's destructor is called // (e.g. during Stop), since |watcher_| internally holds a reference to the // loader and keeps it alive. - scoped_ptr<FilePathWatcher> watcher_; + scoped_ptr<base::files::FilePathWatcher> watcher_; // Settle interval. const base::TimeDelta settle_interval_; diff --git a/chrome/browser/user_style_sheet_watcher.cc b/chrome/browser/user_style_sheet_watcher.cc index 516501d..25dc57b 100644 --- a/chrome/browser/user_style_sheet_watcher.cc +++ b/chrome/browser/user_style_sheet_watcher.cc @@ -9,6 +9,8 @@ #include "content/common/notification_service.h" #include "content/common/notification_type.h" +using ::base::files::FilePathWatcher; + namespace { // The subdirectory of the profile that contains the style sheet. diff --git a/chrome/browser/user_style_sheet_watcher.h b/chrome/browser/user_style_sheet_watcher.h index 7b06dc5..9ea1aac 100644 --- a/chrome/browser/user_style_sheet_watcher.h +++ b/chrome/browser/user_style_sheet_watcher.h @@ -7,10 +7,10 @@ #pragma once #include "base/file_path.h" +#include "base/files/file_path_watcher.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "content/browser/browser_thread.h" -#include "content/common/file_path_watcher/file_path_watcher.h" #include "content/common/notification_observer.h" #include "content/common/notification_registrar.h" #include "googleurl/src/gurl.h" @@ -48,7 +48,7 @@ class UserStyleSheetWatcher scoped_refptr<UserStyleSheetLoader> loader_; // Watches for changes to the css file so we can reload the style sheet. - scoped_ptr<FilePathWatcher> file_watcher_; + scoped_ptr<base::files::FilePathWatcher> file_watcher_; NotificationRegistrar registrar_; diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 02e6aa3..7200e13 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -2372,6 +2372,9 @@ 'test/out_of_proc_test_runner.cc', 'test/render_view_test.cc', 'test/render_view_test.h', + # TODO(craig): Rename this and run from base_unittests when the test + # is safe to run there. See http://crbug.com/78722 for details. + '../base/files/file_path_watcher_browsertest.cc', '../content/browser/child_process_security_policy_browsertest.cc', '../content/browser/device_orientation/device_orientation_browsertest.cc', '../content/browser/in_process_webkit/dom_storage_browsertest.cc', @@ -2387,7 +2390,6 @@ '../content/browser/webui/web_ui_browsertest.h', '../content/browser/webui/web_ui_test_handler.cc', '../content/browser/webui/web_ui_test_handler.h', - '../content/common/file_path_watcher/file_path_watcher_browsertest.cc', '../content/renderer/render_view_browsertest.cc', '../content/renderer/render_view_browsertest_mac.mm', '../content/renderer/render_widget_browsertest.cc', diff --git a/chrome/common/service_process_util_mac.mm b/chrome/common/service_process_util_mac.mm index 62a0371..b5b4f1d6 100644 --- a/chrome/common/service_process_util_mac.mm +++ b/chrome/common/service_process_util_mac.mm @@ -29,6 +29,8 @@ #include "chrome/common/launchd_mac.h" #include "content/common/child_process_host.h" +using ::base::files::FilePathWatcher; + namespace { #define kServiceProcessSessionType "Background" diff --git a/chrome/common/service_process_util_posix.h b/chrome/common/service_process_util_posix.h index 08cca27..a0e8c67 100644 --- a/chrome/common/service_process_util_posix.h +++ b/chrome/common/service_process_util_posix.h @@ -20,8 +20,8 @@ MultiProcessLock* TakeServiceRunningLock(bool waiting); #endif // OS_LINUX #if defined(OS_MACOSX) +#include "base/files/file_path_watcher.h" #include "base/mac/scoped_cftyperef.h" -#include "content/common/file_path_watcher/file_path_watcher.h" class CommandLine; CFDictionaryRef CreateServiceProcessLaunchdPlist(CommandLine* cmd_line, @@ -70,7 +70,7 @@ struct ServiceProcessState::StateData bool WatchExecutable(); base::mac::ScopedCFTypeRef<CFDictionaryRef> launchd_conf_; - FilePathWatcher executable_watcher_; + base::files::FilePathWatcher executable_watcher_; #endif // OS_MACOSX #if defined(OS_LINUX) scoped_ptr<MultiProcessLock> initializing_lock_; diff --git a/content/browser/plugin_service.cc b/content/browser/plugin_service.cc index 7ba4fa5..7bcde62 100644 --- a/content/browser/plugin_service.cc +++ b/content/browser/plugin_service.cc @@ -38,6 +38,10 @@ #include "chrome/browser/chromeos/plugin_selection_policy.h" #endif +#if defined(OS_LINUX) +using ::base::files::FilePathWatcher; +#endif + #if defined(OS_MACOSX) static void NotifyPluginsOfActivation() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); @@ -147,7 +151,6 @@ PluginService::PluginService() &plugin_dirs); for (size_t i = 0; i < plugin_dirs.size(); ++i) { - FilePathWatcher* watcher = new FilePathWatcher(); // FilePathWatcher can not handle non-absolute paths under windows. // We don't watch for file changes in windows now but if this should ever // be extended to Windows these lines might save some time of debugging. @@ -155,6 +158,7 @@ PluginService::PluginService() if (!plugin_dirs[i].IsAbsolute()) continue; #endif + FilePathWatcher* watcher = new FilePathWatcher(); VLOG(1) << "Watching for changes in: " << plugin_dirs[i].value(); BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, diff --git a/content/browser/plugin_service.h b/content/browser/plugin_service.h index 5c37c01..d5c5004 100644 --- a/content/browser/plugin_service.h +++ b/content/browser/plugin_service.h @@ -34,7 +34,7 @@ #endif #if defined(OS_LINUX) -#include "content/common/file_path_watcher/file_path_watcher.h" +#include "base/files/file_path_watcher.h" #endif #if defined(OS_CHROMEOS) @@ -177,9 +177,9 @@ class PluginService #if defined(OS_LINUX) // Registers a new FilePathWatcher for a given path. static void RegisterFilePathWatcher( - FilePathWatcher* watcher, + base::files::FilePathWatcher* watcher, const FilePath& path, - FilePathWatcher::Delegate* delegate); + base::files::FilePathWatcher::Delegate* delegate); #endif // The main thread's message loop. @@ -210,7 +210,7 @@ class PluginService #endif #if defined(OS_LINUX) - ScopedVector<FilePathWatcher> file_watchers_; + ScopedVector<base::files::FilePathWatcher> file_watchers_; scoped_refptr<PluginDirWatcherDelegate> file_watcher_delegate_; #endif diff --git a/content/content_common.gypi b/content/content_common.gypi index f0e16a1..1047715 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -73,11 +73,6 @@ 'common/dx_diag_node.cc', 'common/dx_diag_node.h', 'common/edit_command.h', - 'common/file_path_watcher/file_path_watcher.cc', - 'common/file_path_watcher/file_path_watcher.h', - 'common/file_path_watcher/file_path_watcher_inotify.cc', - 'common/file_path_watcher/file_path_watcher_mac.cc', - 'common/file_path_watcher/file_path_watcher_win.cc', 'common/file_system/file_system_dispatcher.cc', 'common/file_system/file_system_dispatcher.h', 'common/file_system/webfilesystem_callback_dispatcher.cc', @@ -234,16 +229,6 @@ '../third_party/angle/src/build_angle.gyp:libGLESv2', ], }], - ['OS!="linux"', { - 'sources!': [ - 'common/file_path_watcher/file_path_watcher_inotify.cc', - ], - }], - ['OS=="freebsd" or OS=="openbsd"', { - 'sources': [ - 'common/file_path_watcher/file_path_watcher_stub.cc', - ], - }], ['OS=="mac"', { 'sources!': [ 'common/process_watcher_posix.cc', |