OLD | NEW |
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 22 matching lines...) Expand all Loading... |
33 | 33 |
34 #include "core/fileapi/FileError.h" | 34 #include "core/fileapi/FileError.h" |
35 #include "modules/filesystem/EntriesCallback.h" | 35 #include "modules/filesystem/EntriesCallback.h" |
36 #include "modules/filesystem/Entry.h" | 36 #include "modules/filesystem/Entry.h" |
37 #include "modules/filesystem/ErrorCallback.h" | 37 #include "modules/filesystem/ErrorCallback.h" |
38 | 38 |
39 namespace WebCore { | 39 namespace WebCore { |
40 | 40 |
41 class DirectoryReader::EntriesCallbackHelper : public EntriesCallback { | 41 class DirectoryReader::EntriesCallbackHelper : public EntriesCallback { |
42 public: | 42 public: |
43 EntriesCallbackHelper(PassRefPtr<DirectoryReader> reader) | 43 EntriesCallbackHelper(PassRefPtrWillBeRawPtr<DirectoryReader> reader) |
44 : m_reader(reader) | 44 : m_reader(reader) |
45 { | 45 { |
46 } | 46 } |
47 | 47 |
48 virtual void handleEvent(const Vector<RefPtr<Entry> >& entries) OVERRIDE | 48 virtual void handleEvent(const EntryHeapVector& entries) OVERRIDE |
49 { | 49 { |
50 m_reader->addEntries(entries); | 50 m_reader->addEntries(entries); |
51 } | 51 } |
52 | 52 |
53 private: | 53 private: |
54 // FIXME: This RefPtr keeps the reader alive until all of the readDirectory
results are received. crbug.com/350285 | 54 // FIXME: This RefPtr keeps the reader alive until all of the readDirectory
results are received. crbug.com/350285 |
55 RefPtr<DirectoryReader> m_reader; | 55 RefPtrWillBePersistent<DirectoryReader> m_reader; |
56 }; | 56 }; |
57 | 57 |
58 class DirectoryReader::ErrorCallbackHelper : public ErrorCallback { | 58 class DirectoryReader::ErrorCallbackHelper : public ErrorCallback { |
59 public: | 59 public: |
60 ErrorCallbackHelper(PassRefPtr<DirectoryReader> reader) | 60 ErrorCallbackHelper(PassRefPtrWillBeRawPtr<DirectoryReader> reader) |
61 : m_reader(reader) | 61 : m_reader(reader) |
62 { | 62 { |
63 } | 63 } |
64 | 64 |
65 virtual void handleEvent(FileError* error) OVERRIDE | 65 virtual void handleEvent(FileError* error) OVERRIDE |
66 { | 66 { |
67 m_reader->onError(error); | 67 m_reader->onError(error); |
68 } | 68 } |
69 | 69 |
70 private: | 70 private: |
71 RefPtr<DirectoryReader> m_reader; | 71 RefPtrWillBePersistent<DirectoryReader> m_reader; |
72 }; | 72 }; |
73 | 73 |
74 DirectoryReader::DirectoryReader(PassRefPtr<DOMFileSystemBase> fileSystem, const
String& fullPath) | 74 DirectoryReader::DirectoryReader(PassRefPtrWillBeRawPtr<DOMFileSystemBase> fileS
ystem, const String& fullPath) |
75 : DirectoryReaderBase(fileSystem, fullPath) | 75 : DirectoryReaderBase(fileSystem, fullPath) |
76 , m_isReading(false) | 76 , m_isReading(false) |
77 { | 77 { |
78 ScriptWrappable::init(this); | 78 ScriptWrappable::init(this); |
79 } | 79 } |
80 | 80 |
81 DirectoryReader::~DirectoryReader() | 81 DirectoryReader::~DirectoryReader() |
82 { | 82 { |
83 } | 83 } |
84 | 84 |
(...skipping 18 matching lines...) Expand all Loading... |
103 if (!m_hasMoreEntries || !m_entries.isEmpty()) { | 103 if (!m_hasMoreEntries || !m_entries.isEmpty()) { |
104 filesystem()->scheduleCallback(entriesCallback, m_entries); | 104 filesystem()->scheduleCallback(entriesCallback, m_entries); |
105 m_entries.clear(); | 105 m_entries.clear(); |
106 return; | 106 return; |
107 } | 107 } |
108 | 108 |
109 m_entriesCallback = entriesCallback; | 109 m_entriesCallback = entriesCallback; |
110 m_errorCallback = errorCallback; | 110 m_errorCallback = errorCallback; |
111 } | 111 } |
112 | 112 |
113 void DirectoryReader::addEntries(const Vector<RefPtr<Entry> >& entries) | 113 void DirectoryReader::addEntries(const EntryHeapVector& entries) |
114 { | 114 { |
115 m_entries.appendVector(entries); | 115 m_entries.appendVector(entries); |
116 if (m_entriesCallback) { | 116 if (m_entriesCallback) { |
117 OwnPtr<EntriesCallback> entriesCallback = m_entriesCallback.release(); | 117 OwnPtr<EntriesCallback> entriesCallback = m_entriesCallback.release(); |
118 Vector<RefPtr<Entry> > entries; | 118 EntryHeapVector entries; |
119 entries.swap(m_entries); | 119 entries.swap(m_entries); |
120 entriesCallback->handleEvent(entries); | 120 entriesCallback->handleEvent(entries); |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 void DirectoryReader::onError(FileError* error) | 124 void DirectoryReader::onError(FileError* error) |
125 { | 125 { |
126 m_error = error; | 126 m_error = error; |
127 if (m_errorCallback) | 127 if (m_errorCallback) |
128 m_errorCallback->handleEvent(error); | 128 m_errorCallback->handleEvent(error); |
129 } | 129 } |
130 | 130 |
| 131 void DirectoryReader::trace(Visitor* visitor) |
| 132 { |
| 133 visitor->trace(m_entries); |
| 134 visitor->trace(m_error); |
| 135 DirectoryReaderBase::trace(visitor); |
131 } | 136 } |
| 137 |
| 138 } |
OLD | NEW |