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 #include "content/browser/loader/stream_resource_handler.h" | 5 #include "content/browser/loader/stream_resource_handler.h" |
6 | 6 |
7 #include "base/guid.h" | 7 #include "base/guid.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "content/browser/streams/stream.h" | 9 #include "content/browser/streams/stream.h" |
10 #include "content/browser/streams/stream_registry.h" | 10 #include "content/browser/streams/stream_registry.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 int bytes_read, | 81 int bytes_read, |
82 bool* defer) { | 82 bool* defer) { |
83 if (!bytes_read) | 83 if (!bytes_read) |
84 return true; | 84 return true; |
85 | 85 |
86 // We have more data to read. | 86 // We have more data to read. |
87 DCHECK(read_buffer_.get()); | 87 DCHECK(read_buffer_.get()); |
88 | 88 |
89 // Release the ownership of the buffer, and store a reference | 89 // Release the ownership of the buffer, and store a reference |
90 // to it. A new one will be allocated in OnWillRead(). | 90 // to it. A new one will be allocated in OnWillRead(). |
91 net::IOBuffer* buffer = NULL; | 91 scoped_refptr<net::IOBuffer> buffer; |
92 read_buffer_.swap(&buffer); | 92 read_buffer_.swap(buffer); |
93 stream_->AddData(buffer, bytes_read); | 93 stream_->AddData(buffer, bytes_read); |
94 | 94 |
95 if (!stream_->can_add_data()) | 95 if (!stream_->can_add_data()) |
96 *defer = true; | 96 *defer = true; |
97 | 97 |
98 return true; | 98 return true; |
99 } | 99 } |
100 | 100 |
101 void StreamResourceHandler::OnResponseCompleted( | 101 void StreamResourceHandler::OnResponseCompleted( |
102 int request_id, | 102 int request_id, |
(...skipping 11 matching lines...) Expand all Loading... |
114 | 114 |
115 void StreamResourceHandler::OnSpaceAvailable(Stream* stream) { | 115 void StreamResourceHandler::OnSpaceAvailable(Stream* stream) { |
116 controller()->Resume(); | 116 controller()->Resume(); |
117 } | 117 } |
118 | 118 |
119 void StreamResourceHandler::OnClose(Stream* stream) { | 119 void StreamResourceHandler::OnClose(Stream* stream) { |
120 controller()->Cancel(); | 120 controller()->Cancel(); |
121 } | 121 } |
122 | 122 |
123 } // namespace content | 123 } // namespace content |
OLD | NEW |