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

Side by Side Diff: content/browser/streams/stream.h

Issue 15817013: Add Stream support to WebBlobRegistry and FileAPIMessageFilter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Resolve 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #ifndef CONTENT_BROWSER_STREAMS_STREAM_H_ 5 #ifndef CONTENT_BROWSER_STREAMS_STREAM_H_
6 #define CONTENT_BROWSER_STREAMS_STREAM_H_ 6 #define CONTENT_BROWSER_STREAMS_STREAM_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 bool SetReadObserver(StreamReadObserver* observer); 49 bool SetReadObserver(StreamReadObserver* observer);
50 50
51 // Removes the read observer. |observer| must be the current observer. 51 // Removes the read observer. |observer| must be the current observer.
52 void RemoveReadObserver(StreamReadObserver* observer); 52 void RemoveReadObserver(StreamReadObserver* observer);
53 53
54 // Removes the write observer. |observer| must be the current observer. 54 // Removes the write observer. |observer| must be the current observer.
55 void RemoveWriteObserver(StreamWriteObserver* observer); 55 void RemoveWriteObserver(StreamWriteObserver* observer);
56 56
57 // Adds the data in |buffer| to the stream. Takes ownership of |buffer|. 57 // Adds the data in |buffer| to the stream. Takes ownership of |buffer|.
58 void AddData(scoped_refptr<net::IOBuffer> buffer, size_t size); 58 void AddData(scoped_refptr<net::IOBuffer> buffer, size_t size);
59 // Adds data of |size| at |data| to the stream.
kinuko 2013/07/23 13:57:23 nit: can you explicitly comment this copies |data|
tyoshino (SeeGerritForStatus) 2013/07/24 12:14:20 Done.
60 void AddData(const char* data, size_t size);
59 61
60 // Notifies this stream that it will not be receiving any more data. 62 // Notifies this stream that it will not be receiving any more data.
61 void Finalize(); 63 void Finalize();
62 64
63 // Reads a maximum of |buf_size| from the stream into |buf|. Sets 65 // Reads a maximum of |buf_size| from the stream into |buf|. Sets
64 // |*bytes_read| to the number of bytes actually read. 66 // |*bytes_read| to the number of bytes actually read.
65 // Returns STREAM_HAS_DATA if data was read, STREAM_EMPTY if no data was read, 67 // Returns STREAM_HAS_DATA if data was read, STREAM_EMPTY if no data was read,
66 // and STREAM_COMPLETE if the stream is finalized and all data has been read. 68 // and STREAM_COMPLETE if the stream is finalized and all data has been read.
67 StreamState ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read); 69 StreamState ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read);
68 70
69 scoped_ptr<StreamHandle> CreateHandle(const GURL& original_url, 71 scoped_ptr<StreamHandle> CreateHandle(const GURL& original_url,
70 const std::string& mime_type); 72 const std::string& mime_type);
71 void CloseHandle(); 73 void CloseHandle();
72 74
73 // Indicates whether there is space in the buffer to add more data. 75 // Indicates whether there is space in the buffer to add more data.
74 bool can_add_data() const { return can_add_data_; } 76 bool can_add_data() const { return can_add_data_; }
75 77
76 const GURL& url() const { return url_; } 78 const GURL& url() const { return url_; }
77 79
80 // TODO(tyoshino): Once security origin handling inside Chromium is fixed,
81 // revisit callers of the Stream constructor and fix them if necessary to
82 // pass right data (e.g. FileAPIMessageFilter). (crbug.com/263342)
78 const GURL& security_origin() const { return security_origin_; } 83 const GURL& security_origin() const { return security_origin_; }
79 84
80 private: 85 private:
81 friend class base::RefCountedThreadSafe<Stream>; 86 friend class base::RefCountedThreadSafe<Stream>;
82 87
83 virtual ~Stream(); 88 virtual ~Stream();
84 89
85 void OnSpaceAvailable(); 90 void OnSpaceAvailable();
86 void OnDataAvailable(); 91 void OnDataAvailable();
87 92
(...skipping 15 matching lines...) Expand all
103 108
104 StreamHandleImpl* stream_handle_; 109 StreamHandleImpl* stream_handle_;
105 110
106 base::WeakPtrFactory<Stream> weak_ptr_factory_; 111 base::WeakPtrFactory<Stream> weak_ptr_factory_;
107 DISALLOW_COPY_AND_ASSIGN(Stream); 112 DISALLOW_COPY_AND_ASSIGN(Stream);
108 }; 113 };
109 114
110 } // namespace content 115 } // namespace content
111 116
112 #endif // CONTENT_BROWSER_STREAMS_STREAM_H_ 117 #endif // CONTENT_BROWSER_STREAMS_STREAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698