| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/child/webblobregistry_impl.h" | 5 #include "content/child/webblobregistry_impl.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/guid.h" | 8 #include "base/guid.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 static_cast<uint64>(data_item.offset), | 62 static_cast<uint64>(data_item.offset), |
| 63 static_cast<uint64>(data_item.length), | 63 static_cast<uint64>(data_item.length), |
| 64 base::Time::FromDoubleT(data_item.expectedModificationTime)); | 64 base::Time::FromDoubleT(data_item.expectedModificationTime)); |
| 65 sender_->Send( | 65 sender_->Send( |
| 66 new BlobHostMsg_AppendBlobDataItem(uuid_str, item)); | 66 new BlobHostMsg_AppendBlobDataItem(uuid_str, item)); |
| 67 } | 67 } |
| 68 break; | 68 break; |
| 69 case WebBlobData::Item::TypeBlob: | 69 case WebBlobData::Item::TypeBlob: |
| 70 if (data_item.length) { | 70 if (data_item.length) { |
| 71 webkit_blob::BlobData::Item item; | 71 webkit_blob::BlobData::Item item; |
| 72 #ifdef USE_BLOB_UUIDS | |
| 73 item.SetToBlobRange( | 72 item.SetToBlobRange( |
| 74 data_item.blobUUID.utf8(), | 73 data_item.blobUUID.utf8(), |
| 75 static_cast<uint64>(data_item.offset), | 74 static_cast<uint64>(data_item.offset), |
| 76 static_cast<uint64>(data_item.length)); | 75 static_cast<uint64>(data_item.length)); |
| 77 #else | |
| 78 item.SetToBlobUrlRange( | |
| 79 data_item.blobURL, | |
| 80 static_cast<uint64>(data_item.offset), | |
| 81 static_cast<uint64>(data_item.length)); | |
| 82 #endif | |
| 83 sender_->Send( | 76 sender_->Send( |
| 84 new BlobHostMsg_AppendBlobDataItem(uuid_str, item)); | 77 new BlobHostMsg_AppendBlobDataItem(uuid_str, item)); |
| 85 } | 78 } |
| 86 break; | 79 break; |
| 87 case WebBlobData::Item::TypeFileSystemURL: | 80 case WebBlobData::Item::TypeFileSystemURL: |
| 88 if (data_item.length) { | 81 if (data_item.length) { |
| 89 // We only support filesystem URL as of now. | 82 // We only support filesystem URL as of now. |
| 90 DCHECK(GURL(data_item.fileSystemURL).SchemeIsFileSystem()); | 83 DCHECK(GURL(data_item.fileSystemURL).SchemeIsFileSystem()); |
| 91 webkit_blob::BlobData::Item item; | 84 webkit_blob::BlobData::Item item; |
| 92 item.SetToFileSystemUrlRange( | 85 item.SetToFileSystemUrlRange( |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 size_t chunk_size = std::min(data_size, shared_memory_size); | 141 size_t chunk_size = std::min(data_size, shared_memory_size); |
| 149 memcpy(shared_memory->memory(), data_ptr, chunk_size); | 142 memcpy(shared_memory->memory(), data_ptr, chunk_size); |
| 150 sender_->Send(new BlobHostMsg_SyncAppendSharedMemory( | 143 sender_->Send(new BlobHostMsg_SyncAppendSharedMemory( |
| 151 uuid_str, shared_memory->handle(), chunk_size)); | 144 uuid_str, shared_memory->handle(), chunk_size)); |
| 152 data_size -= chunk_size; | 145 data_size -= chunk_size; |
| 153 data_ptr += chunk_size; | 146 data_ptr += chunk_size; |
| 154 } | 147 } |
| 155 } | 148 } |
| 156 } | 149 } |
| 157 | 150 |
| 158 // DEPRECATED, almost. Until blink is updated, we implement these older methods | |
| 159 // in terms of our newer blob storage system. We create a uuid for each 'data' | |
| 160 // we see and construct a mapping from the private blob urls we're given to | |
| 161 // that uuid. The mapping is maintained in the browser process. | |
| 162 // | |
| 163 // Chromium is setup to speak in terms of old-style private blob urls or | |
| 164 // new-style uuid identifiers. Once blink has been migrated support for | |
| 165 // the old-style will be deleted. Search for the term deprecated. | |
| 166 | |
| 167 void WebBlobRegistryImpl::registerBlobURL( | |
| 168 const WebURL& url, WebBlobData& data) { | |
| 169 std::string uuid = base::GenerateGUID(); | |
| 170 registerBlobData(WebKit::WebString::fromUTF8(uuid), data); | |
| 171 sender_->Send(new BlobHostMsg_DeprecatedRegisterBlobURL(url, uuid)); | |
| 172 sender_->Send(new BlobHostMsg_DecrementRefCount(uuid)); | |
| 173 } | |
| 174 | |
| 175 void WebBlobRegistryImpl::registerBlobURL( | |
| 176 const WebURL& url, const WebURL& src_url) { | |
| 177 sender_->Send(new BlobHostMsg_DeprecatedCloneBlobURL(url, src_url)); | |
| 178 } | |
| 179 | |
| 180 void WebBlobRegistryImpl::unregisterBlobURL(const WebURL& url) { | |
| 181 sender_->Send(new BlobHostMsg_DeprecatedRevokeBlobURL(url)); | |
| 182 } | |
| 183 | |
| 184 | |
| 185 // ------ streams stuff ----- | 151 // ------ streams stuff ----- |
| 186 | 152 |
| 187 void WebBlobRegistryImpl::registerStreamURL( | 153 void WebBlobRegistryImpl::registerStreamURL( |
| 188 const WebURL& url, const WebString& content_type) { | 154 const WebURL& url, const WebString& content_type) { |
| 189 DCHECK(ChildThread::current()); | 155 DCHECK(ChildThread::current()); |
| 190 sender_->Send(new StreamHostMsg_StartBuilding(url, content_type.utf8())); | 156 sender_->Send(new StreamHostMsg_StartBuilding(url, content_type.utf8())); |
| 191 } | 157 } |
| 192 | 158 |
| 193 void WebBlobRegistryImpl::registerStreamURL( | 159 void WebBlobRegistryImpl::registerStreamURL( |
| 194 const WebURL& url, const WebURL& src_url) { | 160 const WebURL& url, const WebURL& src_url) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 DCHECK(ChildThread::current()); | 203 DCHECK(ChildThread::current()); |
| 238 sender_->Send(new StreamHostMsg_AbortBuilding(url)); | 204 sender_->Send(new StreamHostMsg_AbortBuilding(url)); |
| 239 } | 205 } |
| 240 | 206 |
| 241 void WebBlobRegistryImpl::unregisterStreamURL(const WebURL& url) { | 207 void WebBlobRegistryImpl::unregisterStreamURL(const WebURL& url) { |
| 242 DCHECK(ChildThread::current()); | 208 DCHECK(ChildThread::current()); |
| 243 sender_->Send(new StreamHostMsg_Remove(url)); | 209 sender_->Send(new StreamHostMsg_Remove(url)); |
| 244 } | 210 } |
| 245 | 211 |
| 246 } // namespace content | 212 } // namespace content |
| OLD | NEW |