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

Side by Side Diff: WebCore/fileapi/FileReaderLoader.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/fileapi/FileReader.cpp ('k') | WebCore/fileapi/ThreadableBlobRegistry.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 18 matching lines...) Expand all
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 32
33 #if ENABLE(BLOB) 33 #if ENABLE(BLOB)
34 34
35 #include "FileReaderLoader.h" 35 #include "FileReaderLoader.h"
36 36
37 #include "Blob.h" 37 #include "Blob.h"
38 #include "BlobURL.h" 38 #include "BlobURL.h"
39 #include "BlobRegistry.h"
39 #include "FileReaderLoaderClient.h" 40 #include "FileReaderLoaderClient.h"
40 #include "ResourceRequest.h" 41 #include "ResourceRequest.h"
41 #include "ResourceResponse.h" 42 #include "ResourceResponse.h"
42 #include "ScriptExecutionContext.h" 43 #include "ScriptExecutionContext.h"
43 #include "TextResourceDecoder.h" 44 #include "TextResourceDecoder.h"
44 #include "ThreadableBlobRegistry.h"
45 #include "ThreadableLoader.h" 45 #include "ThreadableLoader.h"
46 #include <wtf/ArrayBuffer.h> 46 #include <wtf/ArrayBuffer.h>
47 #include <wtf/PassRefPtr.h> 47 #include <wtf/PassRefPtr.h>
48 #include <wtf/RefPtr.h> 48 #include <wtf/RefPtr.h>
49 #include <wtf/Vector.h> 49 #include <wtf/Vector.h>
50 #include <wtf/text/Base64.h> 50 #include <wtf/text/Base64.h>
51 #include <wtf/text/StringBuilder.h> 51 #include <wtf/text/StringBuilder.h>
52 52
53 using namespace std; 53 using namespace std;
54 54
55 namespace WebCore { 55 namespace WebCore {
56 56
57 FileReaderLoader::FileReaderLoader(ReadType readType, FileReaderLoaderClient* cl ient) 57 FileReaderLoader::FileReaderLoader(ReadType readType, FileReaderLoaderClient* cl ient)
58 : m_readType(readType) 58 : m_readType(readType)
59 , m_client(client) 59 , m_client(client)
60 , m_isRawDataConverted(false) 60 , m_isRawDataConverted(false)
61 , m_stringResult("") 61 , m_stringResult("")
62 , m_bytesLoaded(0) 62 , m_bytesLoaded(0)
63 , m_totalBytes(0) 63 , m_totalBytes(0)
64 , m_errorCode(0) 64 , m_errorCode(0)
65 { 65 {
66 } 66 }
67 67
68 FileReaderLoader::~FileReaderLoader() 68 FileReaderLoader::~FileReaderLoader()
69 { 69 {
70 terminate(); 70 terminate();
71 if (!m_urlForReading.isEmpty()) 71 if (!m_urlForReading.isEmpty())
72 ThreadableBlobRegistry::unregisterBlobURL(m_urlForReading); 72 blobRegistry().revokePublicBlobURL(m_urlForReading);
73 } 73 }
74 74
75 void FileReaderLoader::start(ScriptExecutionContext* scriptExecutionContext, Blo b* blob) 75 void FileReaderLoader::start(ScriptExecutionContext* scriptExecutionContext, Blo b* blob)
76 { 76 {
77 ASSERT(m_urlForReading.isEmpty()); // Instances can not be reused.
78
77 // The blob is read by routing through the request handling layer given a te mporary public url. 79 // The blob is read by routing through the request handling layer given a te mporary public url.
78 m_urlForReading = BlobURL::createPublicURL(scriptExecutionContext->securityO rigin()); 80 m_urlForReading = BlobURL::createPublicURL(scriptExecutionContext->securityO rigin());
79 if (m_urlForReading.isEmpty()) { 81 if (m_urlForReading.isEmpty()) {
80 failed(FileError::SECURITY_ERR); 82 failed(FileError::SECURITY_ERR);
81 return; 83 return;
82 } 84 }
83 ThreadableBlobRegistry::registerBlobURL(scriptExecutionContext->securityOrig in(), m_urlForReading, blob->url()); 85 blobRegistry().registerPublicBlobURL(scriptExecutionContext->securityOrigin( ), m_urlForReading, blob->blobDataHandle());
84 86
85 // Construct and load the request. 87 // Construct and load the request.
86 ResourceRequest request(m_urlForReading); 88 ResourceRequest request(m_urlForReading);
87 request.setHTTPMethod("GET"); 89 request.setHTTPMethod("GET");
88 90
89 ThreadableLoaderOptions options; 91 ThreadableLoaderOptions options;
90 options.sendLoadCallbacks = SendCallbacks; 92 options.sendLoadCallbacks = SendCallbacks;
91 options.sniffContent = DoNotSniffContent; 93 options.sniffContent = DoNotSniffContent;
92 options.preflightPolicy = ConsiderPreflight; 94 options.preflightPolicy = ConsiderPreflight;
93 options.allowCredentials = AllowStoredCredentials; 95 options.allowCredentials = AllowStoredCredentials;
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 318
317 void FileReaderLoader::setEncoding(const String& encoding) 319 void FileReaderLoader::setEncoding(const String& encoding)
318 { 320 {
319 if (!encoding.isEmpty()) 321 if (!encoding.isEmpty())
320 m_encoding = TextEncoding(encoding); 322 m_encoding = TextEncoding(encoding);
321 } 323 }
322 324
323 } // namespace WebCore 325 } // namespace WebCore
324 326
325 #endif // ENABLE(BLOB) 327 #endif // ENABLE(BLOB)
OLDNEW
« no previous file with comments | « WebCore/fileapi/FileReader.cpp ('k') | WebCore/fileapi/ThreadableBlobRegistry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698