Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extensions/chrome_url_request_util.h" | 5 #include "chrome/browser/extensions/chrome_url_request_util.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 int GetData(std::string* mime_type, | 62 int GetData(std::string* mime_type, |
| 63 std::string* charset, | 63 std::string* charset, |
| 64 std::string* data, | 64 std::string* data, |
| 65 const net::CompletionCallback& callback) const override { | 65 const net::CompletionCallback& callback) const override { |
| 66 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422489 is fixed. | 66 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422489 is fixed. |
| 67 tracked_objects::ScopedTracker tracking_profile( | 67 tracked_objects::ScopedTracker tracking_profile( |
| 68 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 68 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 69 "422489 URLRequestResourceBundleJob::GetData")); | 69 "422489 URLRequestResourceBundleJob::GetData")); |
| 70 | 70 |
| 71 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 71 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 72 | |
| 73 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422489 is fixed. | |
| 74 tracked_objects::ScopedTracker tracking_profile1( | |
| 75 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 76 "422489 URLRequestResourceBundleJob::GetData 1")); | |
| 77 | |
| 72 *data = rb.GetRawDataResource(resource_id_).as_string(); | 78 *data = rb.GetRawDataResource(resource_id_).as_string(); |
| 73 | 79 |
| 80 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422489 is fixed. | |
| 81 tracked_objects::ScopedTracker tracking_profile2( | |
| 82 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 83 "422489 URLRequestResourceBundleJob::GetData 2")); | |
| 84 | |
| 74 // Add the Content-Length header now that we know the resource length. | 85 // Add the Content-Length header now that we know the resource length. |
| 75 response_info_.headers->AddHeader( | 86 response_info_.headers->AddHeader( |
| 76 base::StringPrintf("%s: %s", | 87 base::StringPrintf("%s: %s", |
| 77 net::HttpRequestHeaders::kContentLength, | 88 net::HttpRequestHeaders::kContentLength, |
| 78 base::UintToString(data->size()).c_str())); | 89 base::UintToString(data->size()).c_str())); |
| 79 | 90 |
| 91 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422489 is fixed. | |
| 92 tracked_objects::ScopedTracker tracking_profile3( | |
| 93 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 94 "422489 URLRequestResourceBundleJob::GetData 3")); | |
| 95 | |
| 80 std::string* read_mime_type = new std::string; | 96 std::string* read_mime_type = new std::string; |
| 81 bool posted = base::PostTaskAndReplyWithResult( | 97 bool posted = base::PostTaskAndReplyWithResult( |
| 82 BrowserThread::GetBlockingPool(), | 98 BrowserThread::GetBlockingPool(), |
| 83 FROM_HERE, | 99 FROM_HERE, |
| 84 base::Bind(&net::GetMimeTypeFromFile, | 100 base::Bind(&net::GetMimeTypeFromFile, |
| 85 filename_, | 101 filename_, |
| 86 base::Unretained(read_mime_type)), | 102 base::Unretained(read_mime_type)), |
|
not at google - send to devlin
2014/10/29 23:34:16
(hopefully it's not one of these Binds, in which c
vadimt
2014/10/29 23:38:20
Acknowledged.
| |
| 87 base::Bind(&URLRequestResourceBundleJob::OnMimeTypeRead, | 103 base::Bind(&URLRequestResourceBundleJob::OnMimeTypeRead, |
| 88 weak_factory_.GetWeakPtr(), | 104 weak_factory_.GetWeakPtr(), |
| 89 mime_type, | 105 mime_type, |
| 90 charset, | 106 charset, |
| 91 data, | 107 data, |
| 92 base::Owned(read_mime_type), | 108 base::Owned(read_mime_type), |
| 93 callback)); | 109 callback)); |
| 94 DCHECK(posted); | 110 DCHECK(posted); |
| 95 | 111 |
| 96 return net::ERR_IO_PENDING; | 112 return net::ERR_IO_PENDING; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 resource_id, | 205 resource_id, |
| 190 content_security_policy, | 206 content_security_policy, |
| 191 send_cors_header); | 207 send_cors_header); |
| 192 } | 208 } |
| 193 } | 209 } |
| 194 return NULL; | 210 return NULL; |
| 195 } | 211 } |
| 196 | 212 |
| 197 } // namespace chrome_url_request_util | 213 } // namespace chrome_url_request_util |
| 198 } // namespace extensions | 214 } // namespace extensions |
| OLD | NEW |