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

Side by Side Diff: third_party/WebKit/Source/modules/filesystem/FileSystemCallbacks.cpp

Issue 2645473005: FileSystem: Migrate ExecutionContextTask to WTF::Closure (Closed)
Patch Set: wrapWeakPersistent Created 3 years, 11 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 | « third_party/WebKit/Source/modules/filesystem/DirectoryReader.cpp ('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 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 bool FileSystemCallbacksBase::shouldScheduleCallback() const { 81 bool FileSystemCallbacksBase::shouldScheduleCallback() const {
82 return !shouldBlockUntilCompletion() && m_executionContext && 82 return !shouldBlockUntilCompletion() && m_executionContext &&
83 m_executionContext->isContextSuspended(); 83 m_executionContext->isContextSuspended();
84 } 84 }
85 85
86 template <typename CB, typename CBArg> 86 template <typename CB, typename CBArg>
87 void FileSystemCallbacksBase::invokeOrScheduleCallback(CB* callback, 87 void FileSystemCallbacksBase::invokeOrScheduleCallback(CB* callback,
88 CBArg arg) { 88 CBArg arg) {
89 DCHECK(callback); 89 DCHECK(callback);
90 if (callback) { 90 if (callback) {
91 if (shouldScheduleCallback()) 91 if (shouldScheduleCallback()) {
92 DOMFileSystem::scheduleCallback( 92 DOMFileSystem::scheduleCallback(
93 m_executionContext.get(), 93 m_executionContext.get(),
94 createSameThreadTask(&CB::invoke, wrapPersistent(callback), arg)); 94 WTF::bind(&CB::invoke, wrapPersistent(callback), arg));
95 else 95 } else {
96 callback->invoke(arg); 96 callback->invoke(arg);
97 }
97 } 98 }
98 m_executionContext.clear(); 99 m_executionContext.clear();
99 } 100 }
100 101
101 template <typename CB, typename CBArg> 102 template <typename CB, typename CBArg>
102 void FileSystemCallbacksBase::handleEventOrScheduleCallback(CB* callback, 103 void FileSystemCallbacksBase::handleEventOrScheduleCallback(CB* callback,
103 CBArg* arg) { 104 CBArg* arg) {
104 DCHECK(callback); 105 DCHECK(callback);
105 if (callback) { 106 if (callback) {
106 if (shouldScheduleCallback()) 107 if (shouldScheduleCallback()) {
107 DOMFileSystem::scheduleCallback( 108 DOMFileSystem::scheduleCallback(
108 m_executionContext.get(), 109 m_executionContext.get(),
109 createSameThreadTask(&CB::handleEvent, wrapPersistent(callback), 110 WTF::bind(&CB::handleEvent, wrapPersistent(callback),
110 wrapPersistent(arg))); 111 wrapPersistent(arg)));
111 else 112 } else {
112 callback->handleEvent(arg); 113 callback->handleEvent(arg);
114 }
113 } 115 }
114 m_executionContext.clear(); 116 m_executionContext.clear();
115 } 117 }
116 118
117 template <typename CB> 119 template <typename CB>
118 void FileSystemCallbacksBase::handleEventOrScheduleCallback(CB* callback) { 120 void FileSystemCallbacksBase::handleEventOrScheduleCallback(CB* callback) {
119 DCHECK(callback); 121 DCHECK(callback);
120 if (callback) { 122 if (callback) {
121 if (shouldScheduleCallback()) 123 if (shouldScheduleCallback()) {
122 DOMFileSystem::scheduleCallback( 124 DOMFileSystem::scheduleCallback(
123 m_executionContext.get(), 125 m_executionContext.get(),
124 createSameThreadTask(&CB::handleEvent, wrapPersistent(callback))); 126 WTF::bind(&CB::handleEvent, wrapPersistent(callback)));
125 else 127 } else {
126 callback->handleEvent(); 128 callback->handleEvent();
129 }
127 } 130 }
128 m_executionContext.clear(); 131 m_executionContext.clear();
129 } 132 }
130 133
131 // ScriptErrorCallback -------------------------------------------------------- 134 // ScriptErrorCallback --------------------------------------------------------
132 135
133 // static 136 // static
134 ScriptErrorCallback* ScriptErrorCallback::wrap(ErrorCallback* callback) { 137 ScriptErrorCallback* ScriptErrorCallback::wrap(ErrorCallback* callback) {
135 // DOMFileSystem operations take an optional (nullable) callback. If a 138 // DOMFileSystem operations take an optional (nullable) callback. If a
136 // script callback was not passed, don't bother creating a dummy wrapper 139 // script callback was not passed, don't bother creating a dummy wrapper
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 DOMFileSystemBase* fileSystem) 422 DOMFileSystemBase* fileSystem)
420 : FileSystemCallbacksBase(errorCallback, fileSystem, context), 423 : FileSystemCallbacksBase(errorCallback, fileSystem, context),
421 m_successCallback(successCallback) {} 424 m_successCallback(successCallback) {}
422 425
423 void VoidCallbacks::didSucceed() { 426 void VoidCallbacks::didSucceed() {
424 if (m_successCallback) 427 if (m_successCallback)
425 handleEventOrScheduleCallback(m_successCallback.release()); 428 handleEventOrScheduleCallback(m_successCallback.release());
426 } 429 }
427 430
428 } // namespace blink 431 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/filesystem/DirectoryReader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698