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

Side by Side Diff: base/files/file_path_watcher_fsevents.cc

Issue 2516353003: Stop checking that FilePathWatcher is used from a MessageLoopForIO. (Closed)
Patch Set: remove patch dependency Created 4 years 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 | « no previous file | base/files/file_path_watcher_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/files/file_path_watcher_fsevents.h" 5 #include "base/files/file_path_watcher_fsevents.h"
6 6
7 #include <dispatch/dispatch.h> 7 #include <dispatch/dispatch.h>
8 8
9 #include <list> 9 #include <list>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/mac/scoped_cftyperef.h" 15 #include "base/mac/scoped_cftyperef.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/message_loop/message_loop.h"
18 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
19 #include "base/threading/thread_task_runner_handle.h" 18 #include "base/threading/thread_task_runner_handle.h"
20 19
21 namespace base { 20 namespace base {
22 21
23 namespace { 22 namespace {
24 23
25 // The latency parameter passed to FSEventsStreamCreate(). 24 // The latency parameter passed to FSEventsStreamCreate().
26 const CFAbsoluteTime kEventLatencySeconds = 0.3; 25 const CFAbsoluteTime kEventLatencySeconds = 0.3;
27 26
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 : queue_(dispatch_queue_create( 71 : queue_(dispatch_queue_create(
73 base::StringPrintf( 72 base::StringPrintf(
74 "org.chromium.base.FilePathWatcher.%p", this).c_str(), 73 "org.chromium.base.FilePathWatcher.%p", this).c_str(),
75 DISPATCH_QUEUE_SERIAL)), 74 DISPATCH_QUEUE_SERIAL)),
76 fsevent_stream_(nullptr) { 75 fsevent_stream_(nullptr) {
77 } 76 }
78 77
79 bool FilePathWatcherFSEvents::Watch(const FilePath& path, 78 bool FilePathWatcherFSEvents::Watch(const FilePath& path,
80 bool recursive, 79 bool recursive,
81 const FilePathWatcher::Callback& callback) { 80 const FilePathWatcher::Callback& callback) {
82 DCHECK(MessageLoopForIO::current());
83 DCHECK(!callback.is_null()); 81 DCHECK(!callback.is_null());
84 DCHECK(callback_.is_null()); 82 DCHECK(callback_.is_null());
85 83
86 // This class could support non-recursive watches, but that is currently 84 // This class could support non-recursive watches, but that is currently
87 // left to FilePathWatcherKQueue. 85 // left to FilePathWatcherKQueue.
88 if (!recursive) 86 if (!recursive)
89 return false; 87 return false;
90 88
91 set_task_runner(ThreadTaskRunnerHandle::Get()); 89 set_task_runner(ThreadTaskRunnerHandle::Get());
92 callback_ = callback; 90 callback_ = callback;
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 void FilePathWatcherFSEvents::StartEventStream(FSEventStreamEventId start_event, 265 void FilePathWatcherFSEvents::StartEventStream(FSEventStreamEventId start_event,
268 const FilePath& path) { 266 const FilePath& path) {
269 DCHECK(resolved_target_.empty()); 267 DCHECK(resolved_target_.empty());
270 268
271 target_ = path; 269 target_ = path;
272 ResolveTargetPath(); 270 ResolveTargetPath();
273 UpdateEventStream(start_event); 271 UpdateEventStream(start_event);
274 } 272 }
275 273
276 } // namespace base 274 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/files/file_path_watcher_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698