Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Side by Side Diff: base/file_util_win.cc

Issue 3427019: Remove logging for issue 35198. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/file_util.h ('k') | chrome/browser/utility_process_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/file_util.h" 5 #include "base/file_util.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <propvarutil.h> 8 #include <propvarutil.h>
9 #include <psapi.h> 9 #include <psapi.h>
10 #include <shellapi.h> 10 #include <shellapi.h>
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 bool CreateNewTempDirectory(const FilePath::StringType& prefix, 586 bool CreateNewTempDirectory(const FilePath::StringType& prefix,
587 FilePath* new_temp_path) { 587 FilePath* new_temp_path) {
588 FilePath system_temp_dir; 588 FilePath system_temp_dir;
589 if (!GetTempDir(&system_temp_dir)) 589 if (!GetTempDir(&system_temp_dir))
590 return false; 590 return false;
591 591
592 return CreateTemporaryDirInDir(system_temp_dir, prefix, new_temp_path); 592 return CreateTemporaryDirInDir(system_temp_dir, prefix, new_temp_path);
593 } 593 }
594 594
595 bool CreateDirectory(const FilePath& full_path) { 595 bool CreateDirectory(const FilePath& full_path) {
596 return file_util::CreateDirectoryExtraLogging(full_path, LOG(INFO));
597 }
598
599 // TODO(skerner): Extra logging has been added to understand crbug/35198 .
600 // Remove it once we get a log from a user who can reproduce the issue.
601 bool CreateDirectoryExtraLogging(const FilePath& full_path,
602 std::ostream& log) {
603 log << "Enter CreateDirectory: full_path = " << full_path.value()
604 << std::endl;
605 // If the path exists, we've succeeded if it's a directory, failed otherwise. 596 // If the path exists, we've succeeded if it's a directory, failed otherwise.
606 const wchar_t* full_path_str = full_path.value().c_str(); 597 const wchar_t* full_path_str = full_path.value().c_str();
607 DWORD fileattr = ::GetFileAttributes(full_path_str); 598 DWORD fileattr = ::GetFileAttributes(full_path_str);
608 log << "::GetFileAttributes() returned " << fileattr << std::endl; 599 if (fileattr != INVALID_FILE_ATTRIBUTES) {
609 if (fileattr == INVALID_FILE_ATTRIBUTES) {
610 DWORD fileattr_error = GetLastError();
611 log << "::GetFileAttributes() failed. GetLastError() = "
612 << fileattr_error << std::endl;
613 } else {
614 if ((fileattr & FILE_ATTRIBUTE_DIRECTORY) != 0) { 600 if ((fileattr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
615 log << "CreateDirectory(" << full_path_str << "), " 601 DLOG(INFO) << "CreateDirectory(" << full_path_str << "), "
616 << "directory already exists." << std::endl; 602 << "directory already exists.";
617 return true; 603 return true;
618 } else { 604 } else {
619 log << "CreateDirectory(" << full_path_str << "), " 605 LOG(WARNING) << "CreateDirectory(" << full_path_str << "), "
620 << "conflicts with existing file." << std::endl; 606 << "conflicts with existing file.";
607 return false;
621 } 608 }
622 } 609 }
623 610
624 // Invariant: Path does not exist as file or directory. 611 // Invariant: Path does not exist as file or directory.
625 612
626 // Attempt to create the parent recursively. This will immediately return 613 // Attempt to create the parent recursively. This will immediately return
627 // true if it already exists, otherwise will create all required parent 614 // true if it already exists, otherwise will create all required parent
628 // directories starting with the highest-level missing parent. 615 // directories starting with the highest-level missing parent.
629 FilePath parent_path(full_path.DirName()); 616 FilePath parent_path(full_path.DirName());
630 if (parent_path.value() == full_path.value()) { 617 if (parent_path.value() == full_path.value()) {
631 log << "Can't create directory: parent_path " << parent_path.value()
632 << " should not equal full_path " << full_path.value()
633 << std::endl;
634 return false; 618 return false;
635 } 619 }
636 if (!CreateDirectory(parent_path)) { 620 if (!CreateDirectory(parent_path)) {
637 log << "Failed to create one of the parent directories: " 621 DLOG(WARNING) << "Failed to create one of the parent directories.";
638 << parent_path.value() << std::endl;
639 return false; 622 return false;
640 } 623 }
641 624
642 log << "About to call ::CreateDirectory() with full_path_str = "
643 << full_path_str << std::endl;
644 if (!::CreateDirectory(full_path_str, NULL)) { 625 if (!::CreateDirectory(full_path_str, NULL)) {
645 DWORD error_code = ::GetLastError(); 626 DWORD error_code = ::GetLastError();
646 log << "CreateDirectory() gave last error " << error_code << std::endl;
647
648 DWORD fileattr = GetFileAttributes(full_path.value().c_str());
649 if (fileattr == INVALID_FILE_ATTRIBUTES) {
650 DWORD fileattr_error = ::GetLastError();
651 log << "GetFileAttributes() failed, GetLastError() = "
652 << fileattr_error << std::endl;
653 } else {
654 log << "GetFileAttributes() returned " << fileattr << std::endl;
655 log << "Is the path a directory: "
656 << ((fileattr & FILE_ATTRIBUTE_DIRECTORY) != 0) << std::endl;
657 }
658 if (error_code == ERROR_ALREADY_EXISTS && DirectoryExists(full_path)) { 627 if (error_code == ERROR_ALREADY_EXISTS && DirectoryExists(full_path)) {
659 // This error code doesn't indicate whether we were racing with someone 628 // This error code doesn't indicate whether we were racing with someone
660 // creating the same directory, or a file with the same path, therefore 629 // creating the same directory, or a file with the same path, therefore
661 // we check. 630 // we check.
662 log << "Race condition? Directory already exists: "
663 << full_path.value() << std::endl;
664 return true; 631 return true;
665 } else { 632 } else {
666 DWORD dir_exists_error = ::GetLastError(); 633 LOG(WARNING) << "Failed to create directory " << full_path_str
667 log << "Failed to create directory " << full_path_str << std::endl; 634 << ", last error is " << error_code << ".";
668 log << "GetLastError() for DirectoryExists() is "
669 << dir_exists_error << std::endl;
670 return false; 635 return false;
671 } 636 }
672 } else { 637 } else {
673 log << "::CreateDirectory() succeeded." << std::endl;
674 return true; 638 return true;
675 } 639 }
676 } 640 }
677 641
678 bool GetFileInfo(const FilePath& file_path, base::PlatformFileInfo* results) { 642 bool GetFileInfo(const FilePath& file_path, base::PlatformFileInfo* results) {
679 WIN32_FILE_ATTRIBUTE_DATA attr; 643 WIN32_FILE_ATTRIBUTE_DATA attr;
680 if (!GetFileAttributesEx(file_path.value().c_str(), 644 if (!GetFileAttributesEx(file_path.value().c_str(),
681 GetFileExInfoStandard, &attr)) { 645 GetFileExInfoStandard, &attr)) {
682 return false; 646 return false;
683 } 647 }
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 uint8 unused = *(touch + offset); 1058 uint8 unused = *(touch + offset);
1095 offset += step_size; 1059 offset += step_size;
1096 } 1060 }
1097 FreeLibrary(dll_module); 1061 FreeLibrary(dll_module);
1098 } 1062 }
1099 1063
1100 return true; 1064 return true;
1101 } 1065 }
1102 1066
1103 } // namespace file_util 1067 } // namespace file_util
OLDNEW
« no previous file with comments | « base/file_util.h ('k') | chrome/browser/utility_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698