Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: WebCore/platform/network/BlobData.cpp

Issue 11192017: ********** WebCore blob hacking (Closed) Base URL: http://svn.webkit.org/repository/webkit/trunk/Source/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « WebCore/platform/network/BlobData.h ('k') | WebCore/platform/network/BlobRegistry.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "BlobData.h" 32 #include "BlobData.h"
33 33
34 #include "BlobRegistry.h"
35 #include "UUID.h"
34 #include <wtf/OwnPtr.h> 36 #include <wtf/OwnPtr.h>
35 #include <wtf/PassOwnPtr.h> 37 #include <wtf/PassOwnPtr.h>
36 #include <wtf/PassRefPtr.h> 38 #include <wtf/PassRefPtr.h>
37 #include <wtf/RefPtr.h> 39 #include <wtf/RefPtr.h>
38 #include <wtf/Vector.h> 40 #include <wtf/Vector.h>
39 41
40 namespace WebCore { 42 namespace WebCore {
41 43
42 const long long BlobDataItem::toEndOfFile = -1; 44 const long long BlobDataItem::toEndOfFile = -1;
43 45
44 RawData::RawData() 46 RawData::RawData()
45 { 47 {
46 } 48 }
47 49
48 void RawData::detachFromCurrentThread() 50 void RawData::detachFromCurrentThread()
49 { 51 {
50 } 52 }
51 53
52 void BlobDataItem::detachFromCurrentThread() 54 void BlobDataItem::detachFromCurrentThread()
53 { 55 {
54 data->detachFromCurrentThread(); 56 data->detachFromCurrentThread();
55 path = path.isolatedCopy(); 57 path = path.isolatedCopy();
56 url = url.copy(); 58 fileSystemURL = fileSystemURL.copy();
57 } 59 }
58 60
59 PassOwnPtr<BlobData> BlobData::create() 61 PassOwnPtr<BlobData> BlobData::create()
60 { 62 {
61 return adoptPtr(new BlobData()); 63 return adoptPtr(new BlobData());
62 } 64 }
63 65
64 void BlobData::detachFromCurrentThread() 66 void BlobData::detachFromCurrentThread()
65 { 67 {
66 m_contentType = m_contentType.isolatedCopy(); 68 m_contentType = m_contentType.isolatedCopy();
(...skipping 10 matching lines...) Expand all
77 void BlobData::appendFile(const String& path) 79 void BlobData::appendFile(const String& path)
78 { 80 {
79 m_items.append(BlobDataItem(path)); 81 m_items.append(BlobDataItem(path));
80 } 82 }
81 83
82 void BlobData::appendFile(const String& path, long long offset, long long length , double expectedModificationTime) 84 void BlobData::appendFile(const String& path, long long offset, long long length , double expectedModificationTime)
83 { 85 {
84 m_items.append(BlobDataItem(path, offset, length, expectedModificationTime)) ; 86 m_items.append(BlobDataItem(path, offset, length, expectedModificationTime)) ;
85 } 87 }
86 88
87 void BlobData::appendBlob(const KURL& url, long long offset, long long length) 89 void BlobData::appendBlob(PassRefPtr<BlobDataHandle> blobDataHandle, long long o ffset, long long length)
88 { 90 {
89 m_items.append(BlobDataItem(url, offset, length)); 91 m_items.append(BlobDataItem(blobDataHandle, offset, length));
90 } 92 }
91 93
92 #if ENABLE(FILE_SYSTEM) 94 #if ENABLE(FILE_SYSTEM)
93 void BlobData::appendURL(const KURL& url, long long offset, long long length, do uble expectedModificationTime) 95 void BlobData::appendFileSystemURL(const KURL& fileSystemURL, long long offset, long long length, double expectedModificationTime)
94 { 96 {
95 m_items.append(BlobDataItem(url, offset, length, expectedModificationTime)); 97 m_items.append(BlobDataItem(fileSystemURL, offset, length, expectedModificat ionTime));
96 } 98 }
97 #endif 99 #endif
98 100
99 void BlobData::swapItems(BlobDataItemList& items) 101 void BlobData::swapItems(BlobDataItemList& items)
100 { 102 {
101 m_items.swap(items); 103 m_items.swap(items);
102 } 104 }
103 105
106
107 // TODO: Maybe we could/should embed the 'type' and 'size' into the id value too ?
108 // In some place we pass just the string id value around and in those places
109 // we have no way of reconstructing the 'type' and 'size'.
110
111 BlobDataHandle::BlobDataHandle()
112 : m_uuid(createCanonicalUUIDString())
113 , m_size(0)
114 {
115 blobRegistry().registerBlobData(m_uuid, BlobData::create());
116 }
117
118 BlobDataHandle::BlobDataHandle(PassOwnPtr<BlobData> data, long long size)
119 : m_uuid(createCanonicalUUIDString())
120 , m_type(data->contentType().isolatedCopy())
121 , m_size(size)
122 {
123 blobRegistry().registerBlobData(m_uuid, data);
124 }
125
126 BlobDataHandle::BlobDataHandle(const String& uuid, const String& type, long long size)
127 : m_uuid(uuid.isolatedCopy())
128 , m_type(type.isolatedCopy())
129 , m_size(size)
130 {
131 blobRegistry().addBlobDataRef(m_uuid);
132 }
133
134 BlobDataHandle::~BlobDataHandle()
135 {
136 blobRegistry().removeBlobDataRef(m_uuid);
137 }
138
104 } // namespace WebCore 139 } // namespace WebCore
OLDNEW
« no previous file with comments | « WebCore/platform/network/BlobData.h ('k') | WebCore/platform/network/BlobRegistry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698