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 "webkit/blob/view_blob_internals_job.h" | 5 #include "webkit/blob/view_blob_internals_job.h" |
6 | 6 |
| 7 #include "base/compiler_specific.h" |
7 #include "base/logging.h" | 8 #include "base/logging.h" |
8 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
9 #include "base/i18n/number_formatting.h" | 10 #include "base/i18n/number_formatting.h" |
10 #include "base/i18n/time_formatting.h" | 11 #include "base/i18n/time_formatting.h" |
11 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
12 #include "base/string_util.h" | 13 #include "base/string_util.h" |
13 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
14 #include "net/base/escape.h" | 15 #include "net/base/escape.h" |
15 #include "net/url_request/url_request.h" | 16 #include "net/url_request/url_request.h" |
16 #include "webkit/blob/blob_data.h" | 17 #include "webkit/blob/blob_data.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 command.c_str()); | 96 command.c_str()); |
96 } | 97 } |
97 | 98 |
98 } // namespace | 99 } // namespace |
99 | 100 |
100 namespace webkit_blob { | 101 namespace webkit_blob { |
101 | 102 |
102 ViewBlobInternalsJob::ViewBlobInternalsJob( | 103 ViewBlobInternalsJob::ViewBlobInternalsJob( |
103 net::URLRequest* request, BlobStorageController* blob_storage_controller) | 104 net::URLRequest* request, BlobStorageController* blob_storage_controller) |
104 : URLRequestSimpleJob(request), | 105 : URLRequestSimpleJob(request), |
105 blob_storage_controller_(blob_storage_controller) { | 106 blob_storage_controller_(blob_storage_controller), |
| 107 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { |
106 } | 108 } |
107 | 109 |
108 ViewBlobInternalsJob::~ViewBlobInternalsJob() { | 110 ViewBlobInternalsJob::~ViewBlobInternalsJob() { |
109 } | 111 } |
110 | 112 |
111 void ViewBlobInternalsJob::Start() { | 113 void ViewBlobInternalsJob::Start() { |
112 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( | 114 MessageLoop::current()->PostTask( |
113 this, &ViewBlobInternalsJob::DoWorkAsync)); | 115 FROM_HERE, |
| 116 method_factory_.NewRunnableMethod(&ViewBlobInternalsJob::DoWorkAsync)); |
114 } | 117 } |
115 | 118 |
116 bool ViewBlobInternalsJob::IsRedirectResponse(GURL* location, | 119 bool ViewBlobInternalsJob::IsRedirectResponse(GURL* location, |
117 int* http_status_code) { | 120 int* http_status_code) { |
118 if (request_->url().has_query()) { | 121 if (request_->url().has_query()) { |
119 // Strip the query parameters. | 122 // Strip the query parameters. |
120 GURL::Replacements replacements; | 123 GURL::Replacements replacements; |
121 replacements.ClearQuery(); | 124 replacements.ClearQuery(); |
122 *location = request_->url().ReplaceComponents(replacements); | 125 *location = request_->url().ReplaceComponents(replacements); |
123 *http_status_code = 307; | 126 *http_status_code = 307; |
124 return true; | 127 return true; |
125 } | 128 } |
126 return false; | 129 return false; |
127 } | 130 } |
128 | 131 |
| 132 void ViewBlobInternalsJob::Kill() { |
| 133 URLRequestSimpleJob::Kill(); |
| 134 method_factory_.RevokeAll(); |
| 135 } |
| 136 |
129 void ViewBlobInternalsJob::DoWorkAsync() { | 137 void ViewBlobInternalsJob::DoWorkAsync() { |
130 if (request_->url().has_query() && | 138 if (request_->url().has_query() && |
131 StartsWithASCII(request_->url().query(), "remove=", true)) { | 139 StartsWithASCII(request_->url().query(), "remove=", true)) { |
132 std::string blob_url = request_->url().query().substr(strlen("remove=")); | 140 std::string blob_url = request_->url().query().substr(strlen("remove=")); |
133 blob_url = UnescapeURLComponent(blob_url, | 141 blob_url = UnescapeURLComponent(blob_url, |
134 UnescapeRule::NORMAL | UnescapeRule::URL_SPECIAL_CHARS); | 142 UnescapeRule::NORMAL | UnescapeRule::URL_SPECIAL_CHARS); |
135 blob_storage_controller_->UnregisterBlobUrl(GURL(blob_url)); | 143 blob_storage_controller_->UnregisterBlobUrl(GURL(blob_url)); |
136 } | 144 } |
137 | 145 |
138 StartAsync(); | 146 StartAsync(); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 } | 230 } |
223 | 231 |
224 if (has_multi_items) | 232 if (has_multi_items) |
225 EndHTMLList(out); | 233 EndHTMLList(out); |
226 } | 234 } |
227 | 235 |
228 EndHTMLList(out); | 236 EndHTMLList(out); |
229 } | 237 } |
230 | 238 |
231 } // namespace webkit_blob | 239 } // namespace webkit_blob |
OLD | NEW |