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 std::string* mime_type, | 62 std::string* mime_type, |
63 std::string* charset, | 63 std::string* charset, |
64 scoped_refptr<base::RefCountedMemory>* data, | 64 scoped_refptr<base::RefCountedMemory>* data, |
65 const net::CompletionCallback& callback) const override { | 65 const net::CompletionCallback& callback) const override { |
66 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 66 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
67 *data = rb.LoadDataResourceBytes(resource_id_); | 67 *data = rb.LoadDataResourceBytes(resource_id_); |
68 | 68 |
69 // Add the Content-Length header now that we know the resource length. | 69 // Add the Content-Length header now that we know the resource length. |
70 response_info_.headers->AddHeader( | 70 response_info_.headers->AddHeader( |
71 base::StringPrintf("%s: %s", net::HttpRequestHeaders::kContentLength, | 71 base::StringPrintf("%s: %s", net::HttpRequestHeaders::kContentLength, |
72 base::UintToString((*data)->size()).c_str())); | 72 base::SizeTToString((*data)->size()).c_str())); |
73 | 73 |
74 std::string* read_mime_type = new std::string; | 74 std::string* read_mime_type = new std::string; |
75 bool posted = base::PostTaskAndReplyWithResult( | 75 bool posted = base::PostTaskAndReplyWithResult( |
76 BrowserThread::GetBlockingPool(), FROM_HERE, | 76 BrowserThread::GetBlockingPool(), FROM_HERE, |
77 base::Bind(&net::GetMimeTypeFromFile, filename_, | 77 base::Bind(&net::GetMimeTypeFromFile, filename_, |
78 base::Unretained(read_mime_type)), | 78 base::Unretained(read_mime_type)), |
79 base::Bind(&URLRequestResourceBundleJob::OnMimeTypeRead, | 79 base::Bind(&URLRequestResourceBundleJob::OnMimeTypeRead, |
80 weak_factory_.GetWeakPtr(), mime_type, charset, *data, | 80 weak_factory_.GetWeakPtr(), mime_type, charset, *data, |
81 base::Owned(read_mime_type), callback)); | 81 base::Owned(read_mime_type), callback)); |
82 DCHECK(posted); | 82 DCHECK(posted); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 resource_id, | 179 resource_id, |
180 content_security_policy, | 180 content_security_policy, |
181 send_cors_header); | 181 send_cors_header); |
182 } | 182 } |
183 } | 183 } |
184 return NULL; | 184 return NULL; |
185 } | 185 } |
186 | 186 |
187 } // namespace chrome_url_request_util | 187 } // namespace chrome_url_request_util |
188 } // namespace extensions | 188 } // namespace extensions |
OLD | NEW |