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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 void handleEvent(const EntryHeapVector& entries) override { | 45 void handleEvent(const EntryHeapVector& entries) override { |
46 m_reader->addEntries(entries); | 46 m_reader->addEntries(entries); |
47 } | 47 } |
48 | 48 |
49 DEFINE_INLINE_VIRTUAL_TRACE() { | 49 DEFINE_INLINE_VIRTUAL_TRACE() { |
50 visitor->trace(m_reader); | 50 visitor->trace(m_reader); |
51 EntriesCallback::trace(visitor); | 51 EntriesCallback::trace(visitor); |
52 } | 52 } |
53 | 53 |
54 private: | 54 private: |
55 // FIXME: This Member keeps the reader alive until all of the readDirectory re
sults are received. crbug.com/350285 | 55 // FIXME: This Member keeps the reader alive until all of the readDirectory |
| 56 // results are received. crbug.com/350285 |
56 Member<DirectoryReader> m_reader; | 57 Member<DirectoryReader> m_reader; |
57 }; | 58 }; |
58 | 59 |
59 class DirectoryReader::ErrorCallbackHelper final : public ErrorCallbackBase { | 60 class DirectoryReader::ErrorCallbackHelper final : public ErrorCallbackBase { |
60 public: | 61 public: |
61 explicit ErrorCallbackHelper(DirectoryReader* reader) : m_reader(reader) {} | 62 explicit ErrorCallbackHelper(DirectoryReader* reader) : m_reader(reader) {} |
62 | 63 |
63 void invoke(FileError::ErrorCode error) override { m_reader->onError(error); } | 64 void invoke(FileError::ErrorCode error) override { m_reader->onError(error); } |
64 | 65 |
65 DEFINE_INLINE_VIRTUAL_TRACE() { | 66 DEFINE_INLINE_VIRTUAL_TRACE() { |
(...skipping 20 matching lines...) Expand all Loading... |
86 new ErrorCallbackHelper(this)); | 87 new ErrorCallbackHelper(this)); |
87 } | 88 } |
88 | 89 |
89 if (m_error) { | 90 if (m_error) { |
90 filesystem()->reportError(ScriptErrorCallback::wrap(errorCallback), | 91 filesystem()->reportError(ScriptErrorCallback::wrap(errorCallback), |
91 m_error); | 92 m_error); |
92 return; | 93 return; |
93 } | 94 } |
94 | 95 |
95 if (m_entriesCallback) { | 96 if (m_entriesCallback) { |
96 // Non-null m_entriesCallback means multiple readEntries() calls are made co
ncurrently. We don't allow doing it. | 97 // Non-null m_entriesCallback means multiple readEntries() calls are made |
| 98 // concurrently. We don't allow doing it. |
97 filesystem()->reportError(ScriptErrorCallback::wrap(errorCallback), | 99 filesystem()->reportError(ScriptErrorCallback::wrap(errorCallback), |
98 FileError::kInvalidStateErr); | 100 FileError::kInvalidStateErr); |
99 return; | 101 return; |
100 } | 102 } |
101 | 103 |
102 if (!m_hasMoreEntries || !m_entries.isEmpty()) { | 104 if (!m_hasMoreEntries || !m_entries.isEmpty()) { |
103 if (entriesCallback) | 105 if (entriesCallback) |
104 DOMFileSystem::scheduleCallback( | 106 DOMFileSystem::scheduleCallback( |
105 filesystem()->getExecutionContext(), | 107 filesystem()->getExecutionContext(), |
106 createSameThreadTask(&EntriesCallback::handleEvent, | 108 createSameThreadTask(&EntriesCallback::handleEvent, |
(...skipping 26 matching lines...) Expand all Loading... |
133 } | 135 } |
134 | 136 |
135 DEFINE_TRACE(DirectoryReader) { | 137 DEFINE_TRACE(DirectoryReader) { |
136 visitor->trace(m_entries); | 138 visitor->trace(m_entries); |
137 visitor->trace(m_entriesCallback); | 139 visitor->trace(m_entriesCallback); |
138 visitor->trace(m_errorCallback); | 140 visitor->trace(m_errorCallback); |
139 DirectoryReaderBase::trace(visitor); | 141 DirectoryReaderBase::trace(visitor); |
140 } | 142 } |
141 | 143 |
142 } // namespace blink | 144 } // namespace blink |
OLD | NEW |