| 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 "components/update_client/utils.h" | 5 #include "components/update_client/utils.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <cstring> | 10 #include <cstring> |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 return request; | 126 return request; |
| 127 } | 127 } |
| 128 | 128 |
| 129 scoped_ptr<net::URLFetcher> SendProtocolRequest( | 129 scoped_ptr<net::URLFetcher> SendProtocolRequest( |
| 130 const GURL& url, | 130 const GURL& url, |
| 131 const std::string& protocol_request, | 131 const std::string& protocol_request, |
| 132 net::URLFetcherDelegate* url_fetcher_delegate, | 132 net::URLFetcherDelegate* url_fetcher_delegate, |
| 133 net::URLRequestContextGetter* url_request_context_getter) { | 133 net::URLRequestContextGetter* url_request_context_getter) { |
| 134 scoped_ptr<net::URLFetcher> url_fetcher = net::URLFetcher::Create( | 134 scoped_ptr<net::URLFetcher> url_fetcher = net::URLFetcher::Create( |
| 135 0, url, net::URLFetcher::POST, url_fetcher_delegate); | 135 0, url, net::URLFetcher::POST, url_fetcher_delegate); |
| 136 if (!url_fetcher.get()) |
| 137 return url_fetcher; |
| 136 | 138 |
| 137 url_fetcher->SetUploadData("application/xml", protocol_request); | 139 url_fetcher->SetUploadData("application/xml", protocol_request); |
| 138 url_fetcher->SetRequestContext(url_request_context_getter); | 140 url_fetcher->SetRequestContext(url_request_context_getter); |
| 139 url_fetcher->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 141 url_fetcher->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 140 net::LOAD_DO_NOT_SAVE_COOKIES | | 142 net::LOAD_DO_NOT_SAVE_COOKIES | |
| 141 net::LOAD_DISABLE_CACHE); | 143 net::LOAD_DISABLE_CACHE); |
| 142 url_fetcher->SetAutomaticallyRetryOn5xx(false); | 144 url_fetcher->SetAutomaticallyRetryOn5xx(false); |
| 143 url_fetcher->Start(); | 145 url_fetcher->Start(); |
| 144 | 146 |
| 145 return url_fetcher; | 147 return url_fetcher; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 uint8_t actual_hash[crypto::kSHA256Length] = {0}; | 220 uint8_t actual_hash[crypto::kSHA256Length] = {0}; |
| 219 scoped_ptr<crypto::SecureHash> hasher( | 221 scoped_ptr<crypto::SecureHash> hasher( |
| 220 crypto::SecureHash::Create(crypto::SecureHash::SHA256)); | 222 crypto::SecureHash::Create(crypto::SecureHash::SHA256)); |
| 221 hasher->Update(mmfile.data(), mmfile.length()); | 223 hasher->Update(mmfile.data(), mmfile.length()); |
| 222 hasher->Finish(actual_hash, sizeof(actual_hash)); | 224 hasher->Finish(actual_hash, sizeof(actual_hash)); |
| 223 | 225 |
| 224 return memcmp(actual_hash, &expected_hash[0], sizeof(actual_hash)) == 0; | 226 return memcmp(actual_hash, &expected_hash[0], sizeof(actual_hash)) == 0; |
| 225 } | 227 } |
| 226 | 228 |
| 227 } // namespace update_client | 229 } // namespace update_client |
| OLD | NEW |