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

Side by Side Diff: Source/core/fileapi/FileReaderLoader.h

Issue 18991017: Add Stream support to FileReaderLoader. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: tkent's comment Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/core/fileapi/FileReaderLoader.cpp » ('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 25 matching lines...) Expand all
36 #include "weborigin/KURL.h" 36 #include "weborigin/KURL.h"
37 #include "wtf/Forward.h" 37 #include "wtf/Forward.h"
38 #include "wtf/text/TextEncoding.h" 38 #include "wtf/text/TextEncoding.h"
39 #include "wtf/text/WTFString.h" 39 #include "wtf/text/WTFString.h"
40 40
41 namespace WebCore { 41 namespace WebCore {
42 42
43 class Blob; 43 class Blob;
44 class FileReaderLoaderClient; 44 class FileReaderLoaderClient;
45 class ScriptExecutionContext; 45 class ScriptExecutionContext;
46 class Stream;
46 class TextResourceDecoder; 47 class TextResourceDecoder;
47 class ThreadableLoader; 48 class ThreadableLoader;
48 49
49 class FileReaderLoader : public ThreadableLoaderClient { 50 class FileReaderLoader : public ThreadableLoaderClient {
50 public: 51 public:
51 enum ReadType { 52 enum ReadType {
52 ReadAsArrayBuffer, 53 ReadAsArrayBuffer,
53 ReadAsBinaryString, 54 ReadAsBinaryString,
54 ReadAsBlob, 55 ReadAsBlob,
55 ReadAsText, 56 ReadAsText,
56 ReadAsDataURL 57 ReadAsDataURL
57 }; 58 };
58 59
59 // If client is given, do the loading asynchronously. Otherwise, load synchr onously. 60 // If client is given, do the loading asynchronously. Otherwise, load synchr onously.
60 FileReaderLoader(ReadType, FileReaderLoaderClient*); 61 FileReaderLoader(ReadType, FileReaderLoaderClient*);
61 ~FileReaderLoader(); 62 ~FileReaderLoader();
62 63
63 void start(ScriptExecutionContext*, Blob*); 64 void start(ScriptExecutionContext*, Blob*);
65 void start(ScriptExecutionContext*, const Stream&);
64 void cancel(); 66 void cancel();
65 67
66 // ThreadableLoaderClient 68 // ThreadableLoaderClient
67 virtual void didReceiveResponse(unsigned long, const ResourceResponse&); 69 virtual void didReceiveResponse(unsigned long, const ResourceResponse&);
68 virtual void didReceiveData(const char*, int); 70 virtual void didReceiveData(const char*, int);
69 virtual void didFinishLoading(unsigned long, double); 71 virtual void didFinishLoading(unsigned long, double);
70 virtual void didFail(const ResourceError&); 72 virtual void didFail(const ResourceError&);
71 73
72 String stringResult(); 74 String stringResult();
73 PassRefPtr<ArrayBuffer> arrayBufferResult() const; 75 PassRefPtr<ArrayBuffer> arrayBufferResult() const;
74 #if ENABLE(STREAM) 76 #if ENABLE(STREAM)
75 PassRefPtr<Blob> blobResult(); 77 PassRefPtr<Blob> blobResult();
76 #endif // ENABLE(STREAM) 78 #endif // ENABLE(STREAM)
77 unsigned bytesLoaded() const { return m_bytesLoaded; } 79 unsigned bytesLoaded() const { return m_bytesLoaded; }
78 unsigned totalBytes() const { return m_totalBytes; } 80 unsigned totalBytes() const { return m_totalBytes; }
79 FileError::ErrorCode errorCode() const { return m_errorCode; } 81 FileError::ErrorCode errorCode() const { return m_errorCode; }
80 82
81 void setEncoding(const String&); 83 void setEncoding(const String&);
82 void setDataType(const String& dataType) { m_dataType = dataType; } 84 void setDataType(const String& dataType) { m_dataType = dataType; }
83 #if ENABLE(STREAM) 85 #if ENABLE(STREAM)
84 void setRange(unsigned, unsigned); 86 void setRange(unsigned, unsigned);
85 #endif // ENABLE(STREAM) 87 #endif // ENABLE(STREAM)
86 88
87 private: 89 private:
90 // We have start() methods for Blob and Stream instead of exposing this
91 // method so that users don't misuse this by calling with non Blob/Stream
92 // URL.
93 void startForURL(ScriptExecutionContext*, const KURL&);
88 void terminate(); 94 void terminate();
89 void cleanup(); 95 void cleanup();
90 void failed(FileError::ErrorCode); 96 void failed(FileError::ErrorCode);
91 void convertToText(); 97 void convertToText();
92 void convertToDataURL(); 98 void convertToDataURL();
93 99
94 bool isCompleted() const; 100 bool isCompleted() const;
95 101
96 static FileError::ErrorCode httpStatusCodeToErrorCode(int); 102 static FileError::ErrorCode httpStatusCodeToErrorCode(int);
97 103
(...skipping 21 matching lines...) Expand all
119 bool m_hasRange; 125 bool m_hasRange;
120 unsigned m_rangeStart; 126 unsigned m_rangeStart;
121 unsigned m_rangeEnd; 127 unsigned m_rangeEnd;
122 128
123 FileError::ErrorCode m_errorCode; 129 FileError::ErrorCode m_errorCode;
124 }; 130 };
125 131
126 } // namespace WebCore 132 } // namespace WebCore
127 133
128 #endif // FileReaderLoader_h 134 #endif // FileReaderLoader_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/fileapi/FileReaderLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698