OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/extension_updater.h" | 5 #include "chrome/browser/extensions/extension_updater.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 MessageLoop* file_io_loop) | 65 MessageLoop* file_io_loop) |
66 : updater_loop_(updater_loop), file_io_loop_(file_io_loop) {} | 66 : updater_loop_(updater_loop), file_io_loop_(file_io_loop) {} |
67 | 67 |
68 // Writes crx file data into a tempfile, and calls back the updater. | 68 // Writes crx file data into a tempfile, and calls back the updater. |
69 void WriteTempFile(const std::string& extension_id, const std::string& data, | 69 void WriteTempFile(const std::string& extension_id, const std::string& data, |
70 scoped_refptr<ExtensionUpdater> updater) { | 70 scoped_refptr<ExtensionUpdater> updater) { |
71 // Make sure we're running in the right thread. | 71 // Make sure we're running in the right thread. |
72 DCHECK(MessageLoop::current() == file_io_loop_); | 72 DCHECK(MessageLoop::current() == file_io_loop_); |
73 | 73 |
74 FilePath path; | 74 FilePath path; |
75 if (!file_util::CreateTemporaryFileName(&path)) { | 75 if (!file_util::CreateTemporaryFile(&path)) { |
76 LOG(WARNING) << "Failed to create temporary file path"; | 76 LOG(WARNING) << "Failed to create temporary file path"; |
77 return; | 77 return; |
78 } | 78 } |
79 if (file_util::WriteFile(path, data.c_str(), data.length()) != | 79 if (file_util::WriteFile(path, data.c_str(), data.length()) != |
80 static_cast<int>(data.length())) { | 80 static_cast<int>(data.length())) { |
81 // TODO(asargent) - It would be nice to back off updating alltogether if | 81 // TODO(asargent) - It would be nice to back off updating alltogether if |
82 // the disk is full. (http://crbug.com/12763). | 82 // the disk is full. (http://crbug.com/12763). |
83 LOG(ERROR) << "Failed to write temporary file"; | 83 LOG(ERROR) << "Failed to write temporary file"; |
84 file_util::Delete(path, false); | 84 file_util::Delete(path, false); |
85 return; | 85 return; |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 } | 737 } |
738 } else { | 738 } else { |
739 extension_fetcher_.reset( | 739 extension_fetcher_.reset( |
740 URLFetcher::Create(kExtensionFetcherId, url, URLFetcher::GET, this)); | 740 URLFetcher::Create(kExtensionFetcherId, url, URLFetcher::GET, this)); |
741 extension_fetcher_->set_request_context( | 741 extension_fetcher_->set_request_context( |
742 Profile::GetDefaultRequestContext()); | 742 Profile::GetDefaultRequestContext()); |
743 extension_fetcher_->Start(); | 743 extension_fetcher_->Start(); |
744 current_extension_fetch_ = ExtensionFetch(id, url, hash, version); | 744 current_extension_fetch_ = ExtensionFetch(id, url, hash, version); |
745 } | 745 } |
746 } | 746 } |
OLD | NEW |