| Index: content/common/file_path_watcher/file_path_watcher.cc
|
| diff --git a/content/common/file_path_watcher/file_path_watcher.cc b/content/common/file_path_watcher/file_path_watcher.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..25c8844efcd5d8647515bdde4b746607d5031a0a
|
| --- /dev/null
|
| +++ b/content/common/file_path_watcher/file_path_watcher.cc
|
| @@ -0,0 +1,43 @@
|
| +// Copyright (c) 2010 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +// 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/logging.h"
|
| +#include "base/message_loop.h"
|
| +
|
| +FilePathWatcher::~FilePathWatcher() {
|
| + impl_->Cancel();
|
| +}
|
| +
|
| +bool FilePathWatcher::Watch(const FilePath& path,
|
| + Delegate* delegate,
|
| + scoped_refptr<base::MessageLoopProxy> loop) {
|
| + DCHECK(path.IsAbsolute());
|
| + impl_->set_message_loop(base::MessageLoopProxy::CreateForCurrentThread());
|
| + return impl_->Watch(path, delegate, loop);
|
| +}
|
| +
|
| +FilePathWatcher::PlatformDelegate::~PlatformDelegate() {
|
| +}
|
| +
|
| +void FilePathWatcher::PlatformDelegate::set_message_loop(
|
| + scoped_refptr<base::MessageLoopProxy> loop) {
|
| + CHECK(!message_loop_.get());
|
| + message_loop_ = loop;
|
| +}
|
| +
|
| +void FilePathWatcher::DeletePlatformDelegate::Destruct(
|
| + const PlatformDelegate* delegate) {
|
| + scoped_refptr<base::MessageLoopProxy> loop = delegate->message_loop();
|
| + if (loop.get() == NULL || loop->BelongsToCurrentThread()) {
|
| + delete delegate;
|
| + } else {
|
| + loop->PostNonNestableTask(FROM_HERE,
|
| + new DeleteTask<PlatformDelegate>(delegate));
|
| + }
|
| +}
|
|
|