diff options
author | rvargas@chromium.org <rvargas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-15 00:09:05 +0000 |
---|---|---|
committer | rvargas@chromium.org <rvargas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-15 00:09:05 +0000 |
commit | 0daaebfe9826bca26d41bf979fa085f26b5ccf95 (patch) | |
tree | 1ab42ee326cf87453e3a340e83385813cdbcb50a | |
parent | 063f03e36ef9f73e300458a2f6cf03b49161348c (diff) | |
download | chromium_src-0daaebfe9826bca26d41bf979fa085f26b5ccf95.zip chromium_src-0daaebfe9826bca26d41bf979fa085f26b5ccf95.tar.gz chromium_src-0daaebfe9826bca26d41bf979fa085f26b5ccf95.tar.bz2 |
Remove CreatePlatformFile from content shell.
BUG=322664
Review URL: https://codereview.chromium.org/184003002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257251 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/file_descriptor_posix.h | 13 | ||||
-rw-r--r-- | chrome/browser/chrome_content_browser_client.cc | 38 | ||||
-rw-r--r-- | chrome/common/local_discovery/local_discovery_messages.h | 6 | ||||
-rw-r--r-- | components/breakpad/browser/crash_dump_manager_android.cc | 20 | ||||
-rw-r--r-- | components/breakpad/browser/crash_dump_manager_android.h | 8 | ||||
-rw-r--r-- | content/browser/renderer_host/media/audio_input_sync_writer.h | 5 | ||||
-rw-r--r-- | content/browser/renderer_host/media/audio_sync_reader.h | 5 | ||||
-rw-r--r-- | content/public/browser/content_browser_client.h | 5 | ||||
-rw-r--r-- | content/shell/browser/shell_content_browser_client.cc | 15 | ||||
-rw-r--r-- | printing/pdf_metafile_skia.cc | 5 |
10 files changed, 69 insertions, 51 deletions
diff --git a/base/file_descriptor_posix.h b/base/file_descriptor_posix.h index abc0789..093dd2f 100644 --- a/base/file_descriptor_posix.h +++ b/base/file_descriptor_posix.h @@ -5,6 +5,8 @@ #ifndef BASE_FILE_DESCRIPTOR_POSIX_H_ #define BASE_FILE_DESCRIPTOR_POSIX_H_ +#include "base/files/file.h" + namespace base { // ----------------------------------------------------------------------------- @@ -16,13 +18,12 @@ namespace base { // above the template specialisation for this structure. // ----------------------------------------------------------------------------- struct FileDescriptor { - FileDescriptor() - : fd(-1), - auto_close(false) { } + FileDescriptor() : fd(-1), auto_close(false) {} + + FileDescriptor(int ifd, bool iauto_close) : fd(ifd), auto_close(iauto_close) { + } - FileDescriptor(int ifd, bool iauto_close) - : fd(ifd), - auto_close(iauto_close) { } + FileDescriptor(File file) : fd(file.TakePlatformFile()), auto_close(true) {} bool operator==(const FileDescriptor& other) const { return (fd == other.fd && auto_close == other.auto_close); diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 0ee29b6..c78cf8c 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -254,7 +254,6 @@ using content::BrowserChildProcessHostIterator; using content::BrowserThread; using content::BrowserURLHandler; using content::ChildProcessSecurityPolicy; -using content::FileDescriptorInfo; using content::QuotaPermissionContext; using content::RenderViewHost; using content::SiteInstance; @@ -265,6 +264,10 @@ using extensions::InfoMap; using extensions::Manifest; using message_center::NotifierId; +#if defined(OS_POSIX) +using content::FileDescriptorInfo; +#endif + namespace { // Cached version of the locale so we can return the locale on the I/O @@ -2595,39 +2598,38 @@ void ChromeContentBrowserClient::GetAdditionalMappedFilesForChildProcess( PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &data_path); DCHECK(!data_path.empty()); - int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; + int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; base::FilePath chrome_resources_pak = data_path.AppendASCII("chrome_100_percent.pak"); - base::PlatformFile f = - base::CreatePlatformFile(chrome_resources_pak, flags, NULL, NULL); - DCHECK(f != base::kInvalidPlatformFileValue); + base::File file(chrome_resources_pak, flags); + DCHECK(file.IsValid()); mappings->push_back(FileDescriptorInfo(kAndroidChrome100PercentPakDescriptor, - FileDescriptor(f, true))); + FileDescriptor(file.Pass()))); const std::string locale = GetApplicationLocale(); base::FilePath locale_pak = ResourceBundle::GetSharedInstance(). GetLocaleFilePath(locale, false); - f = base::CreatePlatformFile(locale_pak, flags, NULL, NULL); - DCHECK(f != base::kInvalidPlatformFileValue); + file.Initialize(locale_pak, flags); + DCHECK(file.IsValid()); mappings->push_back(FileDescriptorInfo(kAndroidLocalePakDescriptor, - FileDescriptor(f, true))); + FileDescriptor(file.Pass()))); base::FilePath resources_pack_path; PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); - f = base::CreatePlatformFile(resources_pack_path, flags, NULL, NULL); - DCHECK(f != base::kInvalidPlatformFileValue); + file.Initialize(resources_pack_path, flags); + DCHECK(file.IsValid()); mappings->push_back(FileDescriptorInfo(kAndroidUIResourcesPakDescriptor, - FileDescriptor(f, true))); + FileDescriptor(file.Pass()))); if (breakpad::IsCrashReporterEnabled()) { - f = breakpad::CrashDumpManager::GetInstance()->CreateMinidumpFile( - child_process_id); - if (f == base::kInvalidPlatformFileValue) { + file = breakpad::CrashDumpManager::GetInstance()->CreateMinidumpFile( + child_process_id); + if (file.IsValid()) { + mappings->push_back(FileDescriptorInfo(kAndroidMinidumpDescriptor, + FileDescriptor(file.Pass()))); + } else { LOG(ERROR) << "Failed to create file for minidump, crash reporting will " "be disabled for this process."; - } else { - mappings->push_back(FileDescriptorInfo(kAndroidMinidumpDescriptor, - FileDescriptor(f, true))); } } diff --git a/chrome/common/local_discovery/local_discovery_messages.h b/chrome/common/local_discovery/local_discovery_messages.h index e34ab6f..e597da3 100644 --- a/chrome/common/local_discovery/local_discovery_messages.h +++ b/chrome/common/local_discovery/local_discovery_messages.h @@ -4,9 +4,9 @@ // Defines local discovery messages between the browser and utility process. +// Multiple-included file, no traditional include guard. #include <vector> -#include "base/file_descriptor_posix.h" #include "chrome/common/local_discovery/service_discovery_client.h" #include "ipc/ipc_message_macros.h" @@ -14,6 +14,10 @@ #define CHROME_COMMON_LOCAL_DISCOVERY_LOCAL_DISCOVERY_MESSAGES_H_ #if defined(OS_POSIX) +#include "base/file_descriptor_posix.h" +#endif + +#if defined(OS_POSIX) struct LocalDiscoveryMsg_SocketInfo { LocalDiscoveryMsg_SocketInfo() : address_family(net::ADDRESS_FAMILY_UNSPECIFIED), diff --git a/components/breakpad/browser/crash_dump_manager_android.cc b/components/breakpad/browser/crash_dump_manager_android.cc index 75d03b2..a8f4c38 100644 --- a/components/breakpad/browser/crash_dump_manager_android.cc +++ b/components/breakpad/browser/crash_dump_manager_android.cc @@ -55,22 +55,20 @@ CrashDumpManager::~CrashDumpManager() { BrowserChildProcessObserver::Remove(this); } -int CrashDumpManager::CreateMinidumpFile(int child_process_id) { +base::File CrashDumpManager::CreateMinidumpFile(int child_process_id) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::PROCESS_LAUNCHER)); base::FilePath minidump_path; if (!base::CreateTemporaryFile(&minidump_path)) - return base::kInvalidPlatformFileValue; + return base::File(); - base::PlatformFileError error; // We need read permission as the minidump is generated in several phases // and needs to be read at some point. - int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ | - base::PLATFORM_FILE_WRITE; - base::PlatformFile minidump_file = - base::CreatePlatformFile(minidump_path, flags, NULL, &error); - if (minidump_file == base::kInvalidPlatformFileValue) { + int flags = base::File::FLAG_OPEN | base::File::FLAG_READ | + base::File::FLAG_WRITE; + base::File minidump_file(minidump_path, flags); + if (!minidump_file.IsValid()) { LOG(ERROR) << "Failed to create temporary file, crash won't be reported."; - return base::kInvalidPlatformFileValue; + return base::File(); } { @@ -78,7 +76,7 @@ int CrashDumpManager::CreateMinidumpFile(int child_process_id) { DCHECK(!ContainsKey(child_process_id_to_minidump_path_, child_process_id)); child_process_id_to_minidump_path_[child_process_id] = minidump_path; } - return minidump_file; + return minidump_file.Pass(); } // static @@ -116,7 +114,7 @@ void CrashDumpManager::ProcessMinidump(const base::FilePath& minidump_path, base::DeleteFile(minidump_path, false); return; } - LOG(INFO) << "Crash minidump successfully generated: " << + VLOG(1) << "Crash minidump successfully generated: " << instance_->crash_dump_dir_.Append(filename).value(); } diff --git a/components/breakpad/browser/crash_dump_manager_android.h b/components/breakpad/browser/crash_dump_manager_android.h index aa79fc6..fdb57d7 100644 --- a/components/breakpad/browser/crash_dump_manager_android.h +++ b/components/breakpad/browser/crash_dump_manager_android.h @@ -7,8 +7,8 @@ #include <map> +#include "base/files/file.h" #include "base/files/file_path.h" -#include "base/platform_file.h" #include "base/process/process.h" #include "base/synchronization/lock.h" #include "content/public/browser/browser_child_process_observer.h" @@ -41,9 +41,9 @@ class CrashDumpManager : public content::BrowserChildProcessObserver, virtual ~CrashDumpManager(); - // Returns a file descriptor that should be used to generate a minidump for - // the process |child_process_id|. - int CreateMinidumpFile(int child_process_id); + // Returns a file that should be used to generate a minidump for the process + // |child_process_id|. + base::File CreateMinidumpFile(int child_process_id); private: typedef std::map<int, base::FilePath> ChildProcessIDToMinidumpPath; diff --git a/content/browser/renderer_host/media/audio_input_sync_writer.h b/content/browser/renderer_host/media/audio_input_sync_writer.h index d16911f..943aaf7 100644 --- a/content/browser/renderer_host/media/audio_input_sync_writer.h +++ b/content/browser/renderer_host/media/audio_input_sync_writer.h @@ -5,11 +5,14 @@ #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_SYNC_WRITER_H_ #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_SYNC_WRITER_H_ -#include "base/file_descriptor_posix.h" #include "base/process/process.h" #include "base/sync_socket.h" #include "media/audio/audio_input_controller.h" +#if defined(OS_POSIX) +#include "base/file_descriptor_posix.h" +#endif + namespace base { class SharedMemory; } diff --git a/content/browser/renderer_host/media/audio_sync_reader.h b/content/browser/renderer_host/media/audio_sync_reader.h index f7db13c..58eb42c 100644 --- a/content/browser/renderer_host/media/audio_sync_reader.h +++ b/content/browser/renderer_host/media/audio_sync_reader.h @@ -5,7 +5,6 @@ #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_SYNC_READER_H_ #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_SYNC_READER_H_ -#include "base/file_descriptor_posix.h" #include "base/process/process.h" #include "base/sync_socket.h" #include "base/synchronization/lock.h" @@ -13,6 +12,10 @@ #include "media/audio/audio_output_controller.h" #include "media/base/audio_bus.h" +#if defined(OS_POSIX) +#include "base/file_descriptor_posix.h" +#endif + namespace base { class SharedMemory; } diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h index e3e8250..5e412a7 100644 --- a/content/public/browser/content_browser_client.h +++ b/content/public/browser/content_browser_client.h @@ -16,7 +16,6 @@ #include "base/memory/scoped_vector.h" #include "base/values.h" #include "content/public/browser/certificate_request_result_type.h" -#include "content/public/browser/file_descriptor_info.h" #include "content/public/common/content_client.h" #include "content/public/common/socket_permission_request.h" #include "content/public/common/window_container_type.h" @@ -31,6 +30,10 @@ #include "base/posix/global_descriptors.h" #endif +#if defined(OS_POSIX) +#include "content/public/browser/file_descriptor_info.h" +#endif + class CommandLine; class GURL; struct WebPreferences; diff --git a/content/shell/browser/shell_content_browser_client.cc b/content/shell/browser/shell_content_browser_client.cc index 7fa6049a..63243b4 100644 --- a/content/shell/browser/shell_content_browser_client.cc +++ b/content/shell/browser/shell_content_browser_client.cc @@ -7,6 +7,7 @@ #include "base/base_switches.h" #include "base/command_line.h" #include "base/file_util.h" +#include "base/files/file.h" #include "base/path_service.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/resource_dispatcher_host.h" @@ -292,25 +293,25 @@ void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( pak_file = pak_file.Append(FILE_PATH_LITERAL("paks")); pak_file = pak_file.Append(FILE_PATH_LITERAL("content_shell.pak")); - base::PlatformFile f = - base::CreatePlatformFile(pak_file, flags, NULL, NULL); - if (f == base::kInvalidPlatformFileValue) { + base::File f(pak_file, flags); + if (!f.IsValid()) { NOTREACHED() << "Failed to open file when creating renderer process: " << "content_shell.pak"; } mappings->push_back( content::FileDescriptorInfo(kShellPakDescriptor, - base::FileDescriptor(f, true))); + base::FileDescriptor(f.Pass()))); if (breakpad::IsCrashReporterEnabled()) { f = breakpad::CrashDumpManager::GetInstance()->CreateMinidumpFile( child_process_id); - if (f == base::kInvalidPlatformFileValue) { + if (!f.IsValid()) { LOG(ERROR) << "Failed to create file for minidump, crash reporting will " << "be disabled for this process."; } else { - mappings->push_back(FileDescriptorInfo(kAndroidMinidumpDescriptor, - base::FileDescriptor(f, true))); + mappings->push_back( + FileDescriptorInfo(kAndroidMinidumpDescriptor, + base::FileDescriptor(f.Pass()))); } } #else // !defined(OS_ANDROID) diff --git a/printing/pdf_metafile_skia.cc b/printing/pdf_metafile_skia.cc index 4e6ceaa..515b3fe 100644 --- a/printing/pdf_metafile_skia.cc +++ b/printing/pdf_metafile_skia.cc @@ -5,7 +5,6 @@ #include "printing/pdf_metafile_skia.h" #include "base/containers/hash_tables.h" -#include "base/file_descriptor_posix.h" #include "base/file_util.h" #include "base/metrics/histogram.h" #include "base/numerics/safe_conversions.h" @@ -27,6 +26,10 @@ #include "printing/pdf_metafile_cg_mac.h" #endif +#if defined(OS_POSIX) +#include "base/file_descriptor_posix.h" +#endif + namespace printing { struct PdfMetafileSkiaData { |