OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "chrome/browser/renderer_host/cross_site_resource_handler.h" | 7 #include "chrome/browser/renderer_host/cross_site_resource_handler.h" |
8 | 8 |
| 9 #include "base/logging.h" |
9 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
10 #include "chrome/browser/renderer_host/render_view_host.h" | 11 #include "chrome/browser/renderer_host/render_view_host.h" |
| 12 #include "net/base/io_buffer.h" |
11 | 13 |
12 namespace { | 14 namespace { |
13 | 15 |
14 // Task to notify the TabContents that a cross-site response has begun, so that | 16 // Task to notify the TabContents that a cross-site response has begun, so that |
15 // TabContents can tell the old page to run its onunload handler. | 17 // TabContents can tell the old page to run its onunload handler. |
16 class CrossSiteNotifyTask : public Task { | 18 class CrossSiteNotifyTask : public Task { |
17 public: | 19 public: |
18 CrossSiteNotifyTask(int render_process_host_id, | 20 CrossSiteNotifyTask(int render_process_host_id, |
19 int render_view_id, | 21 int render_view_id, |
20 int request_id) | 22 int request_id) |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 } | 118 } |
117 | 119 |
118 // Tell the renderer to run the onunload event handler, and wait for the | 120 // Tell the renderer to run the onunload event handler, and wait for the |
119 // reply. | 121 // reply. |
120 StartCrossSiteTransition(request_id, response, global_id); | 122 StartCrossSiteTransition(request_id, response, global_id); |
121 return true; | 123 return true; |
122 } | 124 } |
123 | 125 |
124 bool CrossSiteResourceHandler::OnWillRead(int request_id, net::IOBuffer** buf, | 126 bool CrossSiteResourceHandler::OnWillRead(int request_id, net::IOBuffer** buf, |
125 int* buf_size, int min_size) { | 127 int* buf_size, int min_size) { |
126 return next_handler_->OnWillRead(request_id, buf, buf_size, min_size); | 128 bool rv = next_handler_->OnWillRead(request_id, buf, buf_size, min_size); |
| 129 // TODO(willchan): Remove after debugging bug 16371. |
| 130 if (rv) |
| 131 CHECK((*buf)->data()); |
| 132 return rv; |
127 } | 133 } |
128 | 134 |
129 bool CrossSiteResourceHandler::OnReadCompleted(int request_id, | 135 bool CrossSiteResourceHandler::OnReadCompleted(int request_id, |
130 int* bytes_read) { | 136 int* bytes_read) { |
131 if (!in_cross_site_transition_) { | 137 if (!in_cross_site_transition_) { |
132 return next_handler_->OnReadCompleted(request_id, bytes_read); | 138 return next_handler_->OnReadCompleted(request_id, bytes_read); |
133 } | 139 } |
134 return true; | 140 return true; |
135 } | 141 } |
136 | 142 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 | 260 |
255 // Tell the tab responsible for this request that a cross-site response is | 261 // Tell the tab responsible for this request that a cross-site response is |
256 // starting, so that it can tell its old renderer to run its onunload | 262 // starting, so that it can tell its old renderer to run its onunload |
257 // handler now. We will wait to hear the corresponding ClosePage_ACK. | 263 // handler now. We will wait to hear the corresponding ClosePage_ACK. |
258 CrossSiteNotifyTask* task = | 264 CrossSiteNotifyTask* task = |
259 new CrossSiteNotifyTask(render_process_host_id_, | 265 new CrossSiteNotifyTask(render_process_host_id_, |
260 render_view_id_, | 266 render_view_id_, |
261 request_id); | 267 request_id); |
262 rdh_->ui_loop()->PostTask(FROM_HERE, task); | 268 rdh_->ui_loop()->PostTask(FROM_HERE, task); |
263 } | 269 } |
OLD | NEW |