Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 20 matching lines...) Expand all Loading... | |
| 31 // reader to consume part of the stream, then pass it along to another client | 31 // reader to consume part of the stream, then pass it along to another client |
| 32 // to continue processing the stream. | 32 // to continue processing the stream. |
| 33 class CONTENT_EXPORT Stream : public base::RefCountedThreadSafe<Stream> { | 33 class CONTENT_EXPORT Stream : public base::RefCountedThreadSafe<Stream> { |
| 34 public: | 34 public: |
| 35 enum StreamState { | 35 enum StreamState { |
| 36 STREAM_HAS_DATA, | 36 STREAM_HAS_DATA, |
| 37 STREAM_COMPLETE, | 37 STREAM_COMPLETE, |
| 38 STREAM_EMPTY, | 38 STREAM_EMPTY, |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 // Creates a stream useable from the |security_origin|. | 41 // Creates a stream. |
|
Charlie Reis
2013/07/24 20:33:21
Can you add something about the security origin ch
tyoshino (SeeGerritForStatus)
2013/07/25 03:27:59
Done.
| |
| 42 Stream(StreamRegistry* registry, | 42 Stream(StreamRegistry* registry, |
| 43 StreamWriteObserver* write_observer, | 43 StreamWriteObserver* write_observer, |
| 44 const GURL& security_origin, | |
| 45 const GURL& url); | 44 const GURL& url); |
| 46 | 45 |
| 47 // Sets the reader of this stream. Returns true on success, or false if there | 46 // Sets the reader of this stream. Returns true on success, or false if there |
| 48 // is already a reader. | 47 // is already a reader. |
| 49 bool SetReadObserver(StreamReadObserver* observer); | 48 bool SetReadObserver(StreamReadObserver* observer); |
| 50 | 49 |
| 51 // Removes the read observer. |observer| must be the current observer. | 50 // Removes the read observer. |observer| must be the current observer. |
| 52 void RemoveReadObserver(StreamReadObserver* observer); | 51 void RemoveReadObserver(StreamReadObserver* observer); |
| 53 | 52 |
| 54 // Removes the write observer. |observer| must be the current observer. | 53 // Removes the write observer. |observer| must be the current observer. |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 68 | 67 |
| 69 scoped_ptr<StreamHandle> CreateHandle(const GURL& original_url, | 68 scoped_ptr<StreamHandle> CreateHandle(const GURL& original_url, |
| 70 const std::string& mime_type); | 69 const std::string& mime_type); |
| 71 void CloseHandle(); | 70 void CloseHandle(); |
| 72 | 71 |
| 73 // Indicates whether there is space in the buffer to add more data. | 72 // Indicates whether there is space in the buffer to add more data. |
| 74 bool can_add_data() const { return can_add_data_; } | 73 bool can_add_data() const { return can_add_data_; } |
| 75 | 74 |
| 76 const GURL& url() const { return url_; } | 75 const GURL& url() const { return url_; } |
| 77 | 76 |
| 78 const GURL& security_origin() const { return security_origin_; } | |
| 79 | |
| 80 private: | 77 private: |
| 81 friend class base::RefCountedThreadSafe<Stream>; | 78 friend class base::RefCountedThreadSafe<Stream>; |
| 82 | 79 |
| 83 virtual ~Stream(); | 80 virtual ~Stream(); |
| 84 | 81 |
| 85 void OnSpaceAvailable(); | 82 void OnSpaceAvailable(); |
| 86 void OnDataAvailable(); | 83 void OnDataAvailable(); |
| 87 | 84 |
| 88 size_t data_bytes_read_; | 85 size_t data_bytes_read_; |
| 89 bool can_add_data_; | 86 bool can_add_data_; |
| 90 | 87 |
| 91 GURL security_origin_; | |
| 92 GURL url_; | 88 GURL url_; |
| 93 | 89 |
| 94 scoped_refptr<net::IOBuffer> data_; | 90 scoped_refptr<net::IOBuffer> data_; |
| 95 size_t data_length_; | 91 size_t data_length_; |
| 96 | 92 |
| 97 scoped_ptr<ByteStreamWriter> writer_; | 93 scoped_ptr<ByteStreamWriter> writer_; |
| 98 scoped_ptr<ByteStreamReader> reader_; | 94 scoped_ptr<ByteStreamReader> reader_; |
| 99 | 95 |
| 100 StreamRegistry* registry_; | 96 StreamRegistry* registry_; |
| 101 StreamReadObserver* read_observer_; | 97 StreamReadObserver* read_observer_; |
| 102 StreamWriteObserver* write_observer_; | 98 StreamWriteObserver* write_observer_; |
| 103 | 99 |
| 104 StreamHandleImpl* stream_handle_; | 100 StreamHandleImpl* stream_handle_; |
| 105 | 101 |
| 106 base::WeakPtrFactory<Stream> weak_ptr_factory_; | 102 base::WeakPtrFactory<Stream> weak_ptr_factory_; |
| 107 DISALLOW_COPY_AND_ASSIGN(Stream); | 103 DISALLOW_COPY_AND_ASSIGN(Stream); |
| 108 }; | 104 }; |
| 109 | 105 |
| 110 } // namespace content | 106 } // namespace content |
| 111 | 107 |
| 112 #endif // CONTENT_BROWSER_STREAMS_STREAM_H_ | 108 #endif // CONTENT_BROWSER_STREAMS_STREAM_H_ |
| OLD | NEW |