Chromium Code Reviews| 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 "chrome/installer/test/resource_updater.h" | 5 #include "chrome/installer/test/resource_updater.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
|
brettw
2013/02/22 21:28:15
I wonder if you checked whether some of these file
tfarina
2013/02/22 22:58:54
Done. I ran 'git grep file_util" on all files in t
| |
| 11 #include "base/files/memory_mapped_file.h" | |
| 11 #include "base/logging.h" | 12 #include "base/logging.h" |
| 12 | 13 |
| 13 namespace upgrade_test { | 14 namespace upgrade_test { |
| 14 | 15 |
| 15 ResourceUpdater::ResourceUpdater() : handle_(NULL) { | 16 ResourceUpdater::ResourceUpdater() : handle_(NULL) { |
| 16 } | 17 } |
| 17 | 18 |
| 18 ResourceUpdater::~ResourceUpdater() { | 19 ResourceUpdater::~ResourceUpdater() { |
| 19 if (handle_ != NULL) { | 20 if (handle_ != NULL) { |
| 20 // An update wasn't committed, so discard it. | 21 // An update wasn't committed, so discard it. |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 32 return false; | 33 return false; |
| 33 } | 34 } |
| 34 return true; | 35 return true; |
| 35 } | 36 } |
| 36 | 37 |
| 37 bool ResourceUpdater::Update(const std::wstring& name, | 38 bool ResourceUpdater::Update(const std::wstring& name, |
| 38 const std::wstring& type, | 39 const std::wstring& type, |
| 39 WORD language_id, | 40 WORD language_id, |
| 40 const base::FilePath& input_file) { | 41 const base::FilePath& input_file) { |
| 41 DCHECK(handle_ != NULL); | 42 DCHECK(handle_ != NULL); |
| 42 file_util::MemoryMappedFile input; | 43 base::MemoryMappedFile input; |
| 43 | 44 |
| 44 if (input.Initialize(input_file)) { | 45 if (input.Initialize(input_file)) { |
| 45 if (UpdateResource(handle_, type.c_str(), name.c_str(), language_id, | 46 if (UpdateResource(handle_, type.c_str(), name.c_str(), language_id, |
| 46 const_cast<uint8*>(input.data()), input.length()) | 47 const_cast<uint8*>(input.data()), input.length()) |
| 47 != FALSE) { | 48 != FALSE) { |
| 48 return true; | 49 return true; |
| 49 } | 50 } |
| 50 PLOG(DFATAL) << "UpdateResource failed for resource \"" << name << "\""; | 51 PLOG(DFATAL) << "UpdateResource failed for resource \"" << name << "\""; |
| 51 } else { | 52 } else { |
| 52 PLOG(DFATAL) << "Failed mapping \"" << input_file.value() << "\""; | 53 PLOG(DFATAL) << "Failed mapping \"" << input_file.value() << "\""; |
| 53 } | 54 } |
| 54 return false; | 55 return false; |
| 55 } | 56 } |
| 56 | 57 |
| 57 bool ResourceUpdater::Commit() { | 58 bool ResourceUpdater::Commit() { |
| 58 DCHECK(handle_ != NULL); | 59 DCHECK(handle_ != NULL); |
| 59 bool result = true; | 60 bool result = true; |
| 60 if (EndUpdateResource(handle_, FALSE) == FALSE) { | 61 if (EndUpdateResource(handle_, FALSE) == FALSE) { |
| 61 PLOG(DFATAL) << "EndUpdateResource failed"; | 62 PLOG(DFATAL) << "EndUpdateResource failed"; |
| 62 result = false; | 63 result = false; |
| 63 } | 64 } |
| 64 handle_ = NULL; | 65 handle_ = NULL; |
| 65 return result; | 66 return result; |
| 66 } | 67 } |
| 67 | 68 |
| 68 } // namespace upgrade_test | 69 } // namespace upgrade_test |
| OLD | NEW |