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

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

Issue 8491043: Allow linker initialization of lazy instance (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments + rebase Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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.h" 5 #include "base/files/file_path_watcher.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <string.h> 8 #include <string.h>
9 #include <sys/inotify.h> 9 #include <sys/inotify.h>
10 #include <sys/ioctl.h> 10 #include <sys/ioctl.h>
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 } 211 }
212 212
213 private: 213 private:
214 InotifyReader* reader_; 214 InotifyReader* reader_;
215 int inotify_fd_; 215 int inotify_fd_;
216 int shutdown_fd_; 216 int shutdown_fd_;
217 217
218 DISALLOW_COPY_AND_ASSIGN(InotifyReaderTask); 218 DISALLOW_COPY_AND_ASSIGN(InotifyReaderTask);
219 }; 219 };
220 220
221 static base::LazyInstance<InotifyReader> g_inotify_reader( 221 static base::LazyInstance<InotifyReader> g_inotify_reader =
222 base::LINKER_INITIALIZED); 222 LAZY_INSTANCE_INITIALIZER;
223 223
224 InotifyReader::InotifyReader() 224 InotifyReader::InotifyReader()
225 : thread_("inotify_reader"), 225 : thread_("inotify_reader"),
226 inotify_fd_(inotify_init()), 226 inotify_fd_(inotify_init()),
227 valid_(false) { 227 valid_(false) {
228 shutdown_pipe_[0] = -1; 228 shutdown_pipe_[0] = -1;
229 shutdown_pipe_[1] = -1; 229 shutdown_pipe_[1] = -1;
230 if (inotify_fd_ >= 0 && pipe(shutdown_pipe_) == 0 && thread_.Start()) { 230 if (inotify_fd_ >= 0 && pipe(shutdown_pipe_) == 0 && thread_.Start()) {
231 thread_.message_loop()->PostTask( 231 thread_.message_loop()->PostTask(
232 FROM_HERE, new InotifyReaderTask(this, inotify_fd_, shutdown_pipe_[0])); 232 FROM_HERE, new InotifyReaderTask(this, inotify_fd_, shutdown_pipe_[0]));
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 } 487 }
488 488
489 } // namespace 489 } // namespace
490 490
491 FilePathWatcher::FilePathWatcher() { 491 FilePathWatcher::FilePathWatcher() {
492 impl_ = new FilePathWatcherImpl(); 492 impl_ = new FilePathWatcherImpl();
493 } 493 }
494 494
495 } // namespace files 495 } // namespace files
496 } // namespace base 496 } // namespace base
OLDNEW
« no previous file with comments | « base/debug/trace_event.cc ('k') | base/i18n/number_formatting.cc » ('j') | base/lazy_instance.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698