| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 void WebFileSystemCallbacks::Reset() { | 69 void WebFileSystemCallbacks::Reset() { |
| 70 private_.Reset(); | 70 private_.Reset(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 void WebFileSystemCallbacks::Assign(const WebFileSystemCallbacks& other) { | 73 void WebFileSystemCallbacks::Assign(const WebFileSystemCallbacks& other) { |
| 74 private_ = other.private_; | 74 private_ = other.private_; |
| 75 } | 75 } |
| 76 | 76 |
| 77 void WebFileSystemCallbacks::DidSucceed() { | 77 void WebFileSystemCallbacks::DidSucceed() { |
| 78 ASSERT(!private_.IsNull()); | 78 DCHECK(!private_.IsNull()); |
| 79 private_->Callbacks()->DidSucceed(); | 79 private_->Callbacks()->DidSucceed(); |
| 80 private_.Reset(); | 80 private_.Reset(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void WebFileSystemCallbacks::DidReadMetadata(const WebFileInfo& web_file_info) { | 83 void WebFileSystemCallbacks::DidReadMetadata(const WebFileInfo& web_file_info) { |
| 84 ASSERT(!private_.IsNull()); | 84 DCHECK(!private_.IsNull()); |
| 85 FileMetadata file_metadata; | 85 FileMetadata file_metadata; |
| 86 file_metadata.modification_time = web_file_info.modification_time; | 86 file_metadata.modification_time = web_file_info.modification_time; |
| 87 file_metadata.length = web_file_info.length; | 87 file_metadata.length = web_file_info.length; |
| 88 file_metadata.type = static_cast<FileMetadata::Type>(web_file_info.type); | 88 file_metadata.type = static_cast<FileMetadata::Type>(web_file_info.type); |
| 89 file_metadata.platform_path = web_file_info.platform_path; | 89 file_metadata.platform_path = web_file_info.platform_path; |
| 90 private_->Callbacks()->DidReadMetadata(file_metadata); | 90 private_->Callbacks()->DidReadMetadata(file_metadata); |
| 91 private_.Reset(); | 91 private_.Reset(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void WebFileSystemCallbacks::DidCreateSnapshotFile( | 94 void WebFileSystemCallbacks::DidCreateSnapshotFile( |
| 95 const WebFileInfo& web_file_info) { | 95 const WebFileInfo& web_file_info) { |
| 96 ASSERT(!private_.IsNull()); | 96 DCHECK(!private_.IsNull()); |
| 97 // It's important to create a BlobDataHandle that refers to the platform file | 97 // It's important to create a BlobDataHandle that refers to the platform file |
| 98 // path prior to return from this method so the underlying file will not be | 98 // path prior to return from this method so the underlying file will not be |
| 99 // deleted. | 99 // deleted. |
| 100 std::unique_ptr<BlobData> blob_data = BlobData::Create(); | 100 std::unique_ptr<BlobData> blob_data = BlobData::Create(); |
| 101 blob_data->AppendFile(web_file_info.platform_path, 0, web_file_info.length, | 101 blob_data->AppendFile(web_file_info.platform_path, 0, web_file_info.length, |
| 102 InvalidFileTime()); | 102 InvalidFileTime()); |
| 103 RefPtr<BlobDataHandle> snapshot_blob = | 103 RefPtr<BlobDataHandle> snapshot_blob = |
| 104 BlobDataHandle::Create(std::move(blob_data), web_file_info.length); | 104 BlobDataHandle::Create(std::move(blob_data), web_file_info.length); |
| 105 | 105 |
| 106 FileMetadata file_metadata; | 106 FileMetadata file_metadata; |
| 107 file_metadata.modification_time = web_file_info.modification_time; | 107 file_metadata.modification_time = web_file_info.modification_time; |
| 108 file_metadata.length = web_file_info.length; | 108 file_metadata.length = web_file_info.length; |
| 109 file_metadata.type = static_cast<FileMetadata::Type>(web_file_info.type); | 109 file_metadata.type = static_cast<FileMetadata::Type>(web_file_info.type); |
| 110 file_metadata.platform_path = web_file_info.platform_path; | 110 file_metadata.platform_path = web_file_info.platform_path; |
| 111 private_->Callbacks()->DidCreateSnapshotFile(file_metadata, snapshot_blob); | 111 private_->Callbacks()->DidCreateSnapshotFile(file_metadata, snapshot_blob); |
| 112 private_.Reset(); | 112 private_.Reset(); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void WebFileSystemCallbacks::DidReadDirectory( | 115 void WebFileSystemCallbacks::DidReadDirectory( |
| 116 const WebVector<WebFileSystemEntry>& entries, | 116 const WebVector<WebFileSystemEntry>& entries, |
| 117 bool has_more) { | 117 bool has_more) { |
| 118 ASSERT(!private_.IsNull()); | 118 DCHECK(!private_.IsNull()); |
| 119 for (size_t i = 0; i < entries.size(); ++i) | 119 for (size_t i = 0; i < entries.size(); ++i) |
| 120 private_->Callbacks()->DidReadDirectoryEntry(entries[i].name, | 120 private_->Callbacks()->DidReadDirectoryEntry(entries[i].name, |
| 121 entries[i].is_directory); | 121 entries[i].is_directory); |
| 122 private_->Callbacks()->DidReadDirectoryEntries(has_more); | 122 private_->Callbacks()->DidReadDirectoryEntries(has_more); |
| 123 private_.Reset(); | 123 private_.Reset(); |
| 124 } | 124 } |
| 125 | 125 |
| 126 void WebFileSystemCallbacks::DidOpenFileSystem(const WebString& name, | 126 void WebFileSystemCallbacks::DidOpenFileSystem(const WebString& name, |
| 127 const WebURL& root_url) { | 127 const WebURL& root_url) { |
| 128 ASSERT(!private_.IsNull()); | 128 DCHECK(!private_.IsNull()); |
| 129 private_->Callbacks()->DidOpenFileSystem(name, root_url); | 129 private_->Callbacks()->DidOpenFileSystem(name, root_url); |
| 130 private_.Reset(); | 130 private_.Reset(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void WebFileSystemCallbacks::DidResolveURL(const WebString& name, | 133 void WebFileSystemCallbacks::DidResolveURL(const WebString& name, |
| 134 const WebURL& root_url, | 134 const WebURL& root_url, |
| 135 WebFileSystemType type, | 135 WebFileSystemType type, |
| 136 const WebString& file_path, | 136 const WebString& file_path, |
| 137 bool is_directory) { | 137 bool is_directory) { |
| 138 ASSERT(!private_.IsNull()); | 138 DCHECK(!private_.IsNull()); |
| 139 private_->Callbacks()->DidResolveURL(name, root_url, | 139 private_->Callbacks()->DidResolveURL(name, root_url, |
| 140 static_cast<FileSystemType>(type), | 140 static_cast<FileSystemType>(type), |
| 141 file_path, is_directory); | 141 file_path, is_directory); |
| 142 private_.Reset(); | 142 private_.Reset(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void WebFileSystemCallbacks::DidCreateFileWriter(WebFileWriter* web_file_writer, | 145 void WebFileSystemCallbacks::DidCreateFileWriter(WebFileWriter* web_file_writer, |
| 146 long long length) { | 146 long long length) { |
| 147 ASSERT(!private_.IsNull()); | 147 DCHECK(!private_.IsNull()); |
| 148 private_->Callbacks()->DidCreateFileWriter(WTF::WrapUnique(web_file_writer), | 148 private_->Callbacks()->DidCreateFileWriter(WTF::WrapUnique(web_file_writer), |
| 149 length); | 149 length); |
| 150 private_.Reset(); | 150 private_.Reset(); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void WebFileSystemCallbacks::DidFail(WebFileError error) { | 153 void WebFileSystemCallbacks::DidFail(WebFileError error) { |
| 154 ASSERT(!private_.IsNull()); | 154 DCHECK(!private_.IsNull()); |
| 155 private_->Callbacks()->DidFail(error); | 155 private_->Callbacks()->DidFail(error); |
| 156 private_.Reset(); | 156 private_.Reset(); |
| 157 } | 157 } |
| 158 | 158 |
| 159 bool WebFileSystemCallbacks::ShouldBlockUntilCompletion() const { | 159 bool WebFileSystemCallbacks::ShouldBlockUntilCompletion() const { |
| 160 ASSERT(!private_.IsNull()); | 160 DCHECK(!private_.IsNull()); |
| 161 return private_->Callbacks()->ShouldBlockUntilCompletion(); | 161 return private_->Callbacks()->ShouldBlockUntilCompletion(); |
| 162 } | 162 } |
| 163 | 163 |
| 164 } // namespace blink | 164 } // namespace blink |
| OLD | NEW |