OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/renderer_host/sync_resource_handler.h" | 5 #include "chrome/browser/renderer_host/sync_resource_handler.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/debugger/devtools_netlog_observer.h" | 8 #include "chrome/browser/debugger/devtools_netlog_observer.h" |
9 #include "chrome/browser/net/load_timing_observer.h" | 9 #include "chrome/browser/net/load_timing_observer.h" |
10 #include "chrome/browser/renderer_host/global_request_id.h" | 10 #include "chrome/browser/renderer_host/global_request_id.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 bool SyncResourceHandler::OnUploadProgress(int request_id, | 32 bool SyncResourceHandler::OnUploadProgress(int request_id, |
33 uint64 position, | 33 uint64 position, |
34 uint64 size) { | 34 uint64 size) { |
35 return true; | 35 return true; |
36 } | 36 } |
37 | 37 |
38 bool SyncResourceHandler::OnRequestRedirected(int request_id, | 38 bool SyncResourceHandler::OnRequestRedirected(int request_id, |
39 const GURL& new_url, | 39 const GURL& new_url, |
40 ResourceResponse* response, | 40 ResourceResponse* response, |
41 bool* defer) { | 41 bool* defer) { |
42 URLRequest* request = rdh_->GetURLRequest( | 42 net::URLRequest* request = rdh_->GetURLRequest( |
43 GlobalRequestID(process_id_, request_id)); | 43 GlobalRequestID(process_id_, request_id)); |
44 LoadTimingObserver::PopulateTimingInfo(request, response); | 44 LoadTimingObserver::PopulateTimingInfo(request, response); |
45 DevToolsNetLogObserver::PopulateResponseInfo(request, response); | 45 DevToolsNetLogObserver::PopulateResponseInfo(request, response); |
46 // TODO(darin): It would be much better if this could live in WebCore, but | 46 // TODO(darin): It would be much better if this could live in WebCore, but |
47 // doing so requires API changes at all levels. Similar code exists in | 47 // doing so requires API changes at all levels. Similar code exists in |
48 // WebCore/platform/network/cf/ResourceHandleCFNet.cpp :-( | 48 // WebCore/platform/network/cf/ResourceHandleCFNet.cpp :-( |
49 if (new_url.GetOrigin() != result_.final_url.GetOrigin()) { | 49 if (new_url.GetOrigin() != result_.final_url.GetOrigin()) { |
50 LOG(ERROR) << "Cross origin redirect denied"; | 50 LOG(ERROR) << "Cross origin redirect denied"; |
51 return false; | 51 return false; |
52 } | 52 } |
53 result_.final_url = new_url; | 53 result_.final_url = new_url; |
54 return true; | 54 return true; |
55 } | 55 } |
56 | 56 |
57 bool SyncResourceHandler::OnResponseStarted(int request_id, | 57 bool SyncResourceHandler::OnResponseStarted(int request_id, |
58 ResourceResponse* response) { | 58 ResourceResponse* response) { |
59 URLRequest* request = rdh_->GetURLRequest( | 59 net::URLRequest* request = rdh_->GetURLRequest( |
60 GlobalRequestID(process_id_, request_id)); | 60 GlobalRequestID(process_id_, request_id)); |
61 LoadTimingObserver::PopulateTimingInfo(request, response); | 61 LoadTimingObserver::PopulateTimingInfo(request, response); |
62 DevToolsNetLogObserver::PopulateResponseInfo(request, response); | 62 DevToolsNetLogObserver::PopulateResponseInfo(request, response); |
63 | 63 |
64 // We don't care about copying the status here. | 64 // We don't care about copying the status here. |
65 result_.headers = response->response_head.headers; | 65 result_.headers = response->response_head.headers; |
66 result_.mime_type = response->response_head.mime_type; | 66 result_.mime_type = response->response_head.mime_type; |
67 result_.charset = response->response_head.charset; | 67 result_.charset = response->response_head.charset; |
68 result_.download_file_path = response->response_head.download_file_path; | 68 result_.download_file_path = response->response_head.download_file_path; |
69 result_.request_time = response->response_head.request_time; | 69 result_.request_time = response->response_head.request_time; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 result_message_ = NULL; | 107 result_message_ = NULL; |
108 return true; | 108 return true; |
109 } | 109 } |
110 | 110 |
111 void SyncResourceHandler::OnRequestClosed() { | 111 void SyncResourceHandler::OnRequestClosed() { |
112 if (!result_message_) | 112 if (!result_message_) |
113 return; | 113 return; |
114 | 114 |
115 result_message_->set_reply_error(); | 115 result_message_->set_reply_error(); |
116 receiver_->Send(result_message_); | 116 receiver_->Send(result_message_); |
117 receiver_ = NULL; // URLRequest is gone, and perhaps also the receiver. | 117 receiver_ = NULL; // net::URLRequest is gone, and perhaps also the receiver. |
118 } | 118 } |
OLD | NEW |