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

Unified Diff: Source/modules/filesystem/FileSystemCallbacks.cpp

Issue 383123009: DevTools: Support async call stacks for FileSystem API (part 1). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: Source/modules/filesystem/FileSystemCallbacks.cpp
diff --git a/Source/modules/filesystem/FileSystemCallbacks.cpp b/Source/modules/filesystem/FileSystemCallbacks.cpp
index a1f6fc8f4b32354c6279769e366341ac8389ef29..2a7c3e73dcbc6e0d9dcd324f77750f7126c270c1 100644
--- a/Source/modules/filesystem/FileSystemCallbacks.cpp
+++ b/Source/modules/filesystem/FileSystemCallbacks.cpp
@@ -35,6 +35,7 @@
#include "core/fileapi/File.h"
#include "core/fileapi/FileError.h"
#include "core/html/VoidCallback.h"
+#include "core/inspector/InspectorInstrumentation.h"
#include "modules/filesystem/DOMFilePath.h"
#include "modules/filesystem/DOMFileSystem.h"
#include "modules/filesystem/DOMFileSystemBase.h"
@@ -55,6 +56,34 @@
namespace WebCore {
+namespace {
+
+class HandleCallbackScope FINAL {
+ WTF_MAKE_NONCOPYABLE(HandleCallbackScope);
+public:
+ HandleCallbackScope(PassRefPtrWillBeRawPtr<ExecutionContext> executionContext, FileSystemCallbacksBase* callback, bool reschedule = false, bool hasMore = false)
+ : m_executionContext(executionContext)
+ , m_callback(callback)
+ , m_reschedule(reschedule)
+ {
+ if (m_executionContext)
+ InspectorInstrumentation::willHandleAsyncFileSystemCallback(m_executionContext.get(), m_callback, m_reschedule, hasMore);
yurys 2014/07/14 14:55:54 Consider inlining these instrumentation calls. We
+ }
+
+ ~HandleCallbackScope()
+ {
+ if (m_executionContext)
+ InspectorInstrumentation::didHandleAsyncFileSystemCallback(m_executionContext.get(), m_callback, m_reschedule);
+ }
+
+private:
+ RefPtrWillBePersistent<ExecutionContext> m_executionContext;
+ FileSystemCallbacksBase* m_callback;
+ bool m_reschedule;
+};
+
+} // namespace
+
FileSystemCallbacksBase::FileSystemCallbacksBase(PassOwnPtr<ErrorCallback> errorCallback, DOMFileSystemBase* fileSystem, ExecutionContext* context)
: m_errorCallback(errorCallback)
, m_fileSystem(fileSystem)
@@ -62,10 +91,14 @@ FileSystemCallbacksBase::FileSystemCallbacksBase(PassOwnPtr<ErrorCallback> error
{
if (m_fileSystem)
m_fileSystem->addPendingCallbacks();
+ if (m_executionContext)
+ InspectorInstrumentation::didEnqueueAsyncFileSystemCallback(m_executionContext.get(), this);
}
FileSystemCallbacksBase::~FileSystemCallbacksBase()
{
+ if (m_executionContext)
+ InspectorInstrumentation::didRemoveAsyncFileSystemCallback(m_executionContext.get(), this);
if (m_fileSystem)
m_fileSystem->removePendingCallbacks();
}
@@ -85,10 +118,14 @@ template <typename CB, typename CBArg>
void FileSystemCallbacksBase::handleEventOrScheduleCallback(PassOwnPtr<CB> callback, CBArg* arg)
{
ASSERT(callback.get());
- if (shouldScheduleCallback())
+ if (shouldScheduleCallback()) {
+ HandleCallbackScope scope(m_executionContext, this, true /* reschedule */);
DOMFileSystem::scheduleCallback(m_executionContext.get(), callback, arg);
- else if (callback)
- callback->handleEvent(arg);
+ } else {
+ HandleCallbackScope scope(m_executionContext, this);
+ if (callback)
+ callback->handleEvent(arg);
+ }
m_executionContext.clear();
}
@@ -96,10 +133,14 @@ template <typename CB, typename CBArg>
void FileSystemCallbacksBase::handleEventOrScheduleCallback(PassOwnPtr<CB> callback, PassRefPtrWillBeRawPtr<CBArg> arg)
{
ASSERT(callback.get());
- if (shouldScheduleCallback())
+ if (shouldScheduleCallback()) {
+ HandleCallbackScope scope(m_executionContext, this, true /* reschedule */);
DOMFileSystem::scheduleCallback(m_executionContext.get(), callback, arg);
- else if (callback)
- callback->handleEvent(arg.get());
+ } else {
+ HandleCallbackScope scope(m_executionContext, this);
+ if (callback)
+ callback->handleEvent(arg.get());
+ }
m_executionContext.clear();
}
@@ -107,10 +148,14 @@ template <typename CB>
void FileSystemCallbacksBase::handleEventOrScheduleCallback(PassOwnPtr<CB> callback)
{
ASSERT(callback.get());
- if (shouldScheduleCallback())
+ if (shouldScheduleCallback()) {
+ HandleCallbackScope scope(m_executionContext, this, true /* reschedule */);
DOMFileSystem::scheduleCallback(m_executionContext.get(), callback);
- else if (callback)
- callback->handleEvent();
+ } else {
+ HandleCallbackScope scope(m_executionContext, this);
+ if (callback)
+ callback->handleEvent();
+ }
m_executionContext.clear();
}
@@ -169,6 +214,7 @@ void EntriesCallbacks::didReadDirectoryEntries(bool hasMore)
EntryHeapVector entries;
entries.swap(m_entries);
// FIXME: delay the callback iff shouldScheduleCallback() is true.
+ HandleCallbackScope scope(m_executionContext, this, false /* reschedule */, hasMore);
if (m_successCallback)
m_successCallback->handleEvent(entries);
}
« Source/modules/filesystem/DOMFileSystem.h ('K') | « Source/modules/filesystem/DOMFileSystem.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698