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

Side by Side Diff: chrome/browser/chrome_content_browser_client.cc

Issue 585203002: Turn FileDescriptorInfo a collection class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing android build error Created 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chrome_content_browser_client.h" 5 #include "chrome/browser/chrome_content_browser_client.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/files/scoped_file.h"
13 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
14 #include "base/path_service.h" 15 #include "base/path_service.h"
15 #include "base/prefs/pref_service.h" 16 #include "base/prefs/pref_service.h"
16 #include "base/prefs/scoped_user_pref_update.h" 17 #include "base/prefs/scoped_user_pref_update.h"
17 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
18 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
19 #include "base/threading/sequenced_worker_pool.h" 20 #include "base/threading/sequenced_worker_pool.h"
20 #include "chrome/browser/browser_about_handler.h" 21 #include "chrome/browser/browser_about_handler.h"
21 #include "chrome/browser/browser_process.h" 22 #include "chrome/browser/browser_process.h"
22 #include "chrome/browser/browser_shutdown.h" 23 #include "chrome/browser/browser_shutdown.h"
(...skipping 2371 matching lines...) Expand 10 before | Expand all | Expand 10 after
2394 for (size_t i = 0; i < extra_parts_.size(); ++i) { 2395 for (size_t i = 0; i < extra_parts_.size(); ++i) {
2395 extra_parts_[i]->GetAdditionalFileSystemBackends( 2396 extra_parts_[i]->GetAdditionalFileSystemBackends(
2396 browser_context, storage_partition_path, additional_backends); 2397 browser_context, storage_partition_path, additional_backends);
2397 } 2398 }
2398 } 2399 }
2399 2400
2400 #if defined(OS_POSIX) && !defined(OS_MACOSX) 2401 #if defined(OS_POSIX) && !defined(OS_MACOSX)
2401 void ChromeContentBrowserClient::GetAdditionalMappedFilesForChildProcess( 2402 void ChromeContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
2402 const CommandLine& command_line, 2403 const CommandLine& command_line,
2403 int child_process_id, 2404 int child_process_id,
2404 std::vector<FileDescriptorInfo>* mappings) { 2405 FileDescriptorInfo* mappings) {
2405 #if defined(OS_ANDROID) 2406 #if defined(OS_ANDROID)
2406 base::FilePath data_path; 2407 base::FilePath data_path;
2407 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &data_path); 2408 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &data_path);
2408 DCHECK(!data_path.empty()); 2409 DCHECK(!data_path.empty());
2409 2410
2410 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; 2411 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ;
2411 base::FilePath chrome_resources_pak = 2412 base::FilePath chrome_resources_pak =
2412 data_path.AppendASCII("chrome_100_percent.pak"); 2413 data_path.AppendASCII("chrome_100_percent.pak");
2413 base::File file(chrome_resources_pak, flags); 2414 base::File file(chrome_resources_pak, flags);
2414 DCHECK(file.IsValid()); 2415 DCHECK(file.IsValid());
2415 mappings->push_back(FileDescriptorInfo(kAndroidChrome100PercentPakDescriptor, 2416 mappings->Transfer(kAndroidChrome100PercentPakDescriptor,
2416 FileDescriptor(file.Pass()))); 2417 base::ScopedFD(file.TakePlatformFile()));
2417 2418
2418 const std::string locale = GetApplicationLocale(); 2419 const std::string locale = GetApplicationLocale();
2419 base::FilePath locale_pak = ResourceBundle::GetSharedInstance(). 2420 base::FilePath locale_pak = ResourceBundle::GetSharedInstance().
2420 GetLocaleFilePath(locale, false); 2421 GetLocaleFilePath(locale, false);
2421 file.Initialize(locale_pak, flags); 2422 file.Initialize(locale_pak, flags);
2422 DCHECK(file.IsValid()); 2423 DCHECK(file.IsValid());
2423 mappings->push_back(FileDescriptorInfo(kAndroidLocalePakDescriptor, 2424 mappings->Transfer(kAndroidLocalePakDescriptor,
2424 FileDescriptor(file.Pass()))); 2425 base::ScopedFD(file.TakePlatformFile()));
2425 2426
2426 base::FilePath resources_pack_path; 2427 base::FilePath resources_pack_path;
2427 PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); 2428 PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path);
2428 file.Initialize(resources_pack_path, flags); 2429 file.Initialize(resources_pack_path, flags);
2429 DCHECK(file.IsValid()); 2430 DCHECK(file.IsValid());
2430 mappings->push_back(FileDescriptorInfo(kAndroidUIResourcesPakDescriptor, 2431 mappings->Transfer(kAndroidUIResourcesPakDescriptor,
2431 FileDescriptor(file.Pass()))); 2432 base::ScopedFD(file.TakePlatformFile()));
2432 2433
2433 if (breakpad::IsCrashReporterEnabled()) { 2434 if (breakpad::IsCrashReporterEnabled()) {
2434 file = breakpad::CrashDumpManager::GetInstance()->CreateMinidumpFile( 2435 file = breakpad::CrashDumpManager::GetInstance()->CreateMinidumpFile(
2435 child_process_id); 2436 child_process_id);
2436 if (file.IsValid()) { 2437 if (file.IsValid()) {
2437 mappings->push_back(FileDescriptorInfo(kAndroidMinidumpDescriptor, 2438 mappings->Transfer(kAndroidMinidumpDescriptor,
2438 FileDescriptor(file.Pass()))); 2439 base::ScopedFD(file.TakePlatformFile()));
2439 } else { 2440 } else {
2440 LOG(ERROR) << "Failed to create file for minidump, crash reporting will " 2441 LOG(ERROR) << "Failed to create file for minidump, crash reporting will "
2441 "be disabled for this process."; 2442 "be disabled for this process.";
2442 } 2443 }
2443 } 2444 }
2444 2445
2445 base::FilePath app_data_path; 2446 base::FilePath app_data_path;
2446 PathService::Get(base::DIR_ANDROID_APP_DATA, &app_data_path); 2447 PathService::Get(base::DIR_ANDROID_APP_DATA, &app_data_path);
2447 DCHECK(!app_data_path.empty()); 2448 DCHECK(!app_data_path.empty());
2448 2449
2449 flags = base::File::FLAG_OPEN | base::File::FLAG_READ; 2450 flags = base::File::FLAG_OPEN | base::File::FLAG_READ;
2450 base::FilePath icudata_path = 2451 base::FilePath icudata_path =
2451 app_data_path.AppendASCII("icudtl.dat"); 2452 app_data_path.AppendASCII("icudtl.dat");
2452 base::File icudata_file(icudata_path, flags); 2453 base::File icudata_file(icudata_path, flags);
2453 DCHECK(icudata_file.IsValid()); 2454 DCHECK(icudata_file.IsValid());
2454 mappings->push_back(FileDescriptorInfo(kAndroidICUDataDescriptor, 2455 mappings->Transfer(kAndroidICUDataDescriptor,
2455 FileDescriptor(icudata_file.Pass()))); 2456 base::ScopedFD(icudata_file.TakePlatformFile()));
2456 2457
2457 #else 2458 #else
2458 int crash_signal_fd = GetCrashSignalFD(command_line); 2459 int crash_signal_fd = GetCrashSignalFD(command_line);
2459 if (crash_signal_fd >= 0) { 2460 if (crash_signal_fd >= 0) {
2460 mappings->push_back(FileDescriptorInfo(kCrashDumpSignal, 2461 mappings->Share(kCrashDumpSignal, crash_signal_fd);
2461 FileDescriptor(crash_signal_fd,
2462 false)));
2463 } 2462 }
2464 #endif // defined(OS_ANDROID) 2463 #endif // defined(OS_ANDROID)
2465 } 2464 }
2466 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) 2465 #endif // defined(OS_POSIX) && !defined(OS_MACOSX)
2467 2466
2468 #if defined(OS_WIN) 2467 #if defined(OS_WIN)
2469 const wchar_t* ChromeContentBrowserClient::GetResourceDllName() { 2468 const wchar_t* ChromeContentBrowserClient::GetResourceDllName() {
2470 return chrome::kBrowserResourcesDll; 2469 return chrome::kBrowserResourcesDll;
2471 } 2470 }
2472 2471
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2602 switches::kDisableWebRtcEncryption, 2601 switches::kDisableWebRtcEncryption,
2603 }; 2602 };
2604 to_command_line->CopySwitchesFrom(from_command_line, 2603 to_command_line->CopySwitchesFrom(from_command_line,
2605 kWebRtcDevSwitchNames, 2604 kWebRtcDevSwitchNames,
2606 arraysize(kWebRtcDevSwitchNames)); 2605 arraysize(kWebRtcDevSwitchNames));
2607 } 2606 }
2608 } 2607 }
2609 #endif // defined(ENABLE_WEBRTC) 2608 #endif // defined(ENABLE_WEBRTC)
2610 2609
2611 } // namespace chrome 2610 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698