| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 } | 93 } |
| 94 | 94 |
| 95 void DirectoryReader::readEntries(EntriesCallback* entriesCallback, ErrorCallbac
k* errorCallback) | 95 void DirectoryReader::readEntries(EntriesCallback* entriesCallback, ErrorCallbac
k* errorCallback) |
| 96 { | 96 { |
| 97 if (!m_isReading) { | 97 if (!m_isReading) { |
| 98 m_isReading = true; | 98 m_isReading = true; |
| 99 filesystem()->readDirectory(this, m_fullPath, new EntriesCallbackHelper(
this), new ErrorCallbackHelper(this)); | 99 filesystem()->readDirectory(this, m_fullPath, new EntriesCallbackHelper(
this), new ErrorCallbackHelper(this)); |
| 100 } | 100 } |
| 101 | 101 |
| 102 if (m_error) { | 102 if (m_error) { |
| 103 filesystem()->scheduleCallback(errorCallback, m_error); | 103 filesystem()->reportError(errorCallback, m_error.get()); |
| 104 return; | 104 return; |
| 105 } | 105 } |
| 106 | 106 |
| 107 if (m_entriesCallback) { | 107 if (m_entriesCallback) { |
| 108 // Non-null m_entriesCallback means multiple readEntries() calls are mad
e concurrently. We don't allow doing it. | 108 // Non-null m_entriesCallback means multiple readEntries() calls are mad
e concurrently. We don't allow doing it. |
| 109 filesystem()->scheduleCallback(errorCallback, FileError::create(FileErro
r::INVALID_STATE_ERR)); | 109 filesystem()->reportError(errorCallback, FileError::create(FileError::IN
VALID_STATE_ERR)); |
| 110 return; | 110 return; |
| 111 } | 111 } |
| 112 | 112 |
| 113 if (!m_hasMoreEntries || !m_entries.isEmpty()) { | 113 if (!m_hasMoreEntries || !m_entries.isEmpty()) { |
| 114 filesystem()->scheduleCallback(entriesCallback, m_entries); | 114 if (entriesCallback) |
| 115 DOMFileSystem::scheduleCallback(filesystem()->getExecutionContext(),
createSameThreadTask(&EntriesCallback::handleEvent, wrapPersistent(entriesCallb
ack), PersistentHeapVector<Member<Entry>>(m_entries))); |
| 115 m_entries.clear(); | 116 m_entries.clear(); |
| 116 return; | 117 return; |
| 117 } | 118 } |
| 118 | 119 |
| 119 m_entriesCallback = entriesCallback; | 120 m_entriesCallback = entriesCallback; |
| 120 m_errorCallback = errorCallback; | 121 m_errorCallback = errorCallback; |
| 121 } | 122 } |
| 122 | 123 |
| 123 void DirectoryReader::addEntries(const EntryHeapVector& entries) | 124 void DirectoryReader::addEntries(const EntryHeapVector& entries) |
| 124 { | 125 { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 145 DEFINE_TRACE(DirectoryReader) | 146 DEFINE_TRACE(DirectoryReader) |
| 146 { | 147 { |
| 147 visitor->trace(m_entries); | 148 visitor->trace(m_entries); |
| 148 visitor->trace(m_error); | 149 visitor->trace(m_error); |
| 149 visitor->trace(m_entriesCallback); | 150 visitor->trace(m_entriesCallback); |
| 150 visitor->trace(m_errorCallback); | 151 visitor->trace(m_errorCallback); |
| 151 DirectoryReaderBase::trace(visitor); | 152 DirectoryReaderBase::trace(visitor); |
| 152 } | 153 } |
| 153 | 154 |
| 154 } // namespace blink | 155 } // namespace blink |
| OLD | NEW |