Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <sstream> | 5 #include <sstream> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <shlwapi.h> | 10 #include <shlwapi.h> |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 if (file_util::Delete(download_path, false)) | 126 if (file_util::Delete(download_path, false)) |
| 127 break; | 127 break; |
| 128 PlatformThread::Sleep(action_max_timeout_ms() / 10); | 128 PlatformThread::Sleep(action_max_timeout_ms() / 10); |
| 129 } | 129 } |
| 130 EXPECT_FALSE(file_util::PathExists(download_path)); | 130 EXPECT_FALSE(file_util::PathExists(download_path)); |
| 131 } | 131 } |
| 132 | 132 |
| 133 #if defined(OS_WIN) | 133 #if defined(OS_WIN) |
| 134 // Checks if the ZoneIdentifier is correctly set to "Internet" (3) | 134 // Checks if the ZoneIdentifier is correctly set to "Internet" (3) |
| 135 void CheckZoneIdentifier(const std::wstring full_path) { | 135 void CheckZoneIdentifier(const std::wstring full_path) { |
| 136 const DWORD kShare = FILE_SHARE_READ | | |
| 137 FILE_SHARE_WRITE | | |
| 138 FILE_SHARE_DELETE; | |
| 139 | |
| 140 std::wstring path = full_path + L":Zone.Identifier"; | 136 std::wstring path = full_path + L":Zone.Identifier"; |
| 141 HANDLE file = CreateFile(path.c_str(), GENERIC_READ, kShare, NULL, | |
| 142 OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); | |
| 143 ASSERT_TRUE(INVALID_HANDLE_VALUE != file); | |
| 144 | 137 |
| 145 // This polling and sleeping here is a very bad pattern. But due to how | 138 // This polling and sleeping here is a very bad pattern. But due to how |
| 146 // Windows file semantics work it's really hard to do it other way. We are | 139 // Windows file semantics work it's really hard to do it other way. We are |
| 147 // reading a file written by a different process, using a different handle. | 140 // reading a file written by a different process, using a different handle. |
| 148 // Windows does not guarantee that we will get the same contents even after | 141 // Windows does not guarantee that we will get the same contents even after |
| 149 // the other process closes the handle, flushes the buffers, etc. | 142 // the other process closes the handle, flushes the buffers, etc. |
| 150 for (int i = 0; i < 20; i++) { | 143 for (int i = 0; i < 20; i++) { |
| 151 PlatformThread::Sleep(sleep_timeout_ms()); | 144 PlatformThread::Sleep(sleep_timeout_ms()); |
| 152 | 145 |
| 146 const DWORD kShare = FILE_SHARE_READ | | |
| 147 FILE_SHARE_WRITE | | |
| 148 FILE_SHARE_DELETE; | |
| 149 HANDLE file = CreateFile(path.c_str(), GENERIC_READ, kShare, NULL, | |
| 150 OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); | |
| 151 if (file == INVALID_HANDLE_VALUE) | |
| 152 continue; | |
| 153 | |
| 153 char buffer[100] = {0}; | 154 char buffer[100] = {0}; |
| 154 DWORD read = 0; | 155 DWORD read = 0; |
| 155 BOOL read_result = ReadFile(file, buffer, 100, &read, NULL); | 156 BOOL read_result = ReadFile(file, buffer, 100, &read, NULL); |
| 156 CloseHandle(file); | 157 CloseHandle(file); |
|
cpu_(ooo_6.6-7.5)
2009/09/18 18:08:18
So I see that the CloseHandle of line 156 was a bu
| |
| 157 | 158 |
| 158 if (!read_result) | 159 if (!read_result) |
| 159 continue; | 160 continue; |
| 160 | 161 |
| 161 const char kIdentifier[] = "[ZoneTransfer]\nZoneId=3"; | 162 const char kIdentifier[] = "[ZoneTransfer]\nZoneId=3"; |
| 162 if (read != arraysize(kIdentifier)) | 163 if (read != arraysize(kIdentifier)) |
| 163 continue; | 164 continue; |
| 164 | 165 |
| 165 if (strcmp(kIdentifier, buffer) == 0) | 166 if (strcmp(kIdentifier, buffer) == 0) |
| 166 return; | 167 return; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 347 ASSERT_EQ(1, window_count); | 348 ASSERT_EQ(1, window_count); |
| 348 | 349 |
| 349 // Verify that the regular window does not have a download shelf. | 350 // Verify that the regular window does not have a download shelf. |
| 350 browser->IsShelfVisible(&is_shelf_visible); | 351 browser->IsShelfVisible(&is_shelf_visible); |
| 351 EXPECT_FALSE(is_shelf_visible); | 352 EXPECT_FALSE(is_shelf_visible); |
| 352 | 353 |
| 353 CleanUpDownload(file); | 354 CleanUpDownload(file); |
| 354 } | 355 } |
| 355 | 356 |
| 356 } // namespace | 357 } // namespace |
| OLD | NEW |