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

Side by Side Diff: Source/modules/filesystem/DirectoryReaderSync.cpp

Issue 188503002: Oilpan: add transition types to FileSystem APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 9 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
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 26 matching lines...) Expand all
37 #include "modules/filesystem/DirectoryEntrySync.h" 37 #include "modules/filesystem/DirectoryEntrySync.h"
38 #include "modules/filesystem/EntriesCallback.h" 38 #include "modules/filesystem/EntriesCallback.h"
39 #include "modules/filesystem/EntrySync.h" 39 #include "modules/filesystem/EntrySync.h"
40 #include "modules/filesystem/ErrorCallback.h" 40 #include "modules/filesystem/ErrorCallback.h"
41 #include "modules/filesystem/FileEntrySync.h" 41 #include "modules/filesystem/FileEntrySync.h"
42 42
43 namespace WebCore { 43 namespace WebCore {
44 44
45 class DirectoryReaderSync::EntriesCallbackHelper : public EntriesCallback { 45 class DirectoryReaderSync::EntriesCallbackHelper : public EntriesCallback {
46 public: 46 public:
47 EntriesCallbackHelper(PassRefPtr<DirectoryReaderSync> reader) 47 EntriesCallbackHelper(PassRefPtrWillBeRawPtr<DirectoryReaderSync> reader)
48 : m_reader(reader) 48 : m_reader(reader)
49 { 49 {
50 } 50 }
51 51
52 virtual void handleEvent(const Vector<RefPtr<Entry> >& entries) OVERRIDE 52 virtual void handleEvent(const EntryHeapVector& entries) OVERRIDE
53 { 53 {
54 EntrySyncVector syncEntries; 54 EntrySyncHeapVector syncEntries;
55 syncEntries.reserveInitialCapacity(entries.size()); 55 syncEntries.reserveInitialCapacity(entries.size());
56 for (size_t i = 0; i < entries.size(); ++i) 56 for (size_t i = 0; i < entries.size(); ++i)
57 syncEntries.uncheckedAppend(EntrySync::create(entries[i].get())); 57 syncEntries.uncheckedAppend(EntrySync::create(entries[i].get()));
58 m_reader->addEntries(syncEntries); 58 m_reader->addEntries(syncEntries);
59 } 59 }
60 60
61 private: 61 private:
62 RefPtr<DirectoryReaderSync> m_reader; 62 RefPtrWillBePersistent<DirectoryReaderSync> m_reader;
63 }; 63 };
64 64
65 class DirectoryReaderSync::ErrorCallbackHelper : public ErrorCallback { 65 class DirectoryReaderSync::ErrorCallbackHelper : public ErrorCallback {
66 public: 66 public:
67 ErrorCallbackHelper(PassRefPtr<DirectoryReaderSync> reader) 67 ErrorCallbackHelper(PassRefPtrWillBeRawPtr<DirectoryReaderSync> reader)
68 : m_reader(reader) 68 : m_reader(reader)
69 { 69 {
70 } 70 }
71 71
72 virtual void handleEvent(FileError* error) OVERRIDE 72 virtual void handleEvent(FileError* error) OVERRIDE
73 { 73 {
74 m_reader->setError(error->code()); 74 m_reader->setError(error->code());
75 } 75 }
76 76
77 private: 77 private:
78 RefPtr<DirectoryReaderSync> m_reader; 78 RefPtrWillBePersistent<DirectoryReaderSync> m_reader;
79 }; 79 };
80 80
81 DirectoryReaderSync::DirectoryReaderSync(PassRefPtr<DOMFileSystemBase> fileSyste m, const String& fullPath) 81 DirectoryReaderSync::DirectoryReaderSync(PassRefPtrWillBeRawPtr<DOMFileSystemBas e> fileSystem, const String& fullPath)
82 : DirectoryReaderBase(fileSystem, fullPath) 82 : DirectoryReaderBase(fileSystem, fullPath)
83 , m_callbacksId(0) 83 , m_callbacksId(0)
84 , m_errorCode(FileError::OK) 84 , m_errorCode(FileError::OK)
85 { 85 {
86 ScriptWrappable::init(this); 86 ScriptWrappable::init(this);
87 } 87 }
88 88
89 DirectoryReaderSync::~DirectoryReaderSync() 89 DirectoryReaderSync::~DirectoryReaderSync()
90 { 90 {
91 } 91 }
92 92
93 EntrySyncVector DirectoryReaderSync::readEntries(ExceptionState& exceptionState) 93 EntrySyncHeapVector DirectoryReaderSync::readEntries(ExceptionState& exceptionSt ate)
94 { 94 {
95 if (!m_callbacksId) { 95 if (!m_callbacksId) {
96 m_callbacksId = filesystem()->readDirectory(this, m_fullPath, adoptPtr(n ew EntriesCallbackHelper(this)), adoptPtr(new ErrorCallbackHelper(this)), DOMFil eSystemBase::Synchronous); 96 m_callbacksId = filesystem()->readDirectory(this, m_fullPath, adoptPtr(n ew EntriesCallbackHelper(this)), adoptPtr(new ErrorCallbackHelper(this)), DOMFil eSystemBase::Synchronous);
97 } 97 }
98 98
99 if (m_errorCode == FileError::OK && m_hasMoreEntries && m_entries.isEmpty()) 99 if (m_errorCode == FileError::OK && m_hasMoreEntries && m_entries.isEmpty())
100 m_fileSystem->waitForAdditionalResult(m_callbacksId); 100 m_fileSystem->waitForAdditionalResult(m_callbacksId);
101 101
102 if (m_errorCode != FileError::OK) { 102 if (m_errorCode != FileError::OK) {
103 FileError::throwDOMException(exceptionState, m_errorCode); 103 FileError::throwDOMException(exceptionState, m_errorCode);
104 return EntrySyncVector(); 104 return EntrySyncHeapVector();
105 } 105 }
106 106
107 EntrySyncVector result; 107 EntrySyncHeapVector result;
108 result.swap(m_entries); 108 result.swap(m_entries);
109 return result; 109 return result;
110 } 110 }
111 111
112 void DirectoryReaderSync::trace(Visitor* visitor)
113 {
114 visitor->trace(m_entries);
115 DirectoryReaderBase::trace(visitor);
116 }
117
112 } // namespace 118 } // namespace
OLDNEW
« no previous file with comments | « Source/modules/filesystem/DirectoryReaderSync.h ('k') | Source/modules/filesystem/DirectoryReaderSync.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698