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

Side by Side Diff: content/shell/browser/shell_content_browser_client.cc

Issue 585203002: Turn FileDescriptorInfo a collection class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/shell/browser/shell_content_browser_client.h" 5 #include "content/shell/browser/shell_content_browser_client.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file.h" 9 #include "base/files/file.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 ResourceContext* resource_context, 345 ResourceContext* resource_context,
346 const GURL& current_url, 346 const GURL& current_url,
347 const GURL& new_url) { 347 const GURL& new_url) {
348 return g_swap_processes_for_redirect; 348 return g_swap_processes_for_redirect;
349 } 349 }
350 350
351 #if defined(OS_POSIX) && !defined(OS_MACOSX) 351 #if defined(OS_POSIX) && !defined(OS_MACOSX)
352 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( 352 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
353 const CommandLine& command_line, 353 const CommandLine& command_line,
354 int child_process_id, 354 int child_process_id,
355 std::vector<FileDescriptorInfo>* mappings) { 355 FileDescriptorInfo* mappings) {
356 #if defined(OS_ANDROID) 356 #if defined(OS_ANDROID)
357 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; 357 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ;
358 base::FilePath pak_file; 358 base::FilePath pak_file;
359 bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file); 359 bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file);
360 CHECK(r); 360 CHECK(r);
361 pak_file = pak_file.Append(FILE_PATH_LITERAL("paks")); 361 pak_file = pak_file.Append(FILE_PATH_LITERAL("paks"));
362 pak_file = pak_file.Append(FILE_PATH_LITERAL("content_shell.pak")); 362 pak_file = pak_file.Append(FILE_PATH_LITERAL("content_shell.pak"));
363 363
364 base::File f(pak_file, flags); 364 base::File f(pak_file, flags);
365 if (!f.IsValid()) { 365 if (!f.IsValid()) {
366 NOTREACHED() << "Failed to open file when creating renderer process: " 366 NOTREACHED() << "Failed to open file when creating renderer process: "
367 << "content_shell.pak"; 367 << "content_shell.pak";
368 } 368 }
369 mappings->push_back( 369
370 FileDescriptorInfo(kShellPakDescriptor, base::FileDescriptor(f.Pass()))); 370 mappings->Transfer(kShellPakDescriptor, base::ScopedFD(f.TakePlatformFile()));
371 371
372 if (breakpad::IsCrashReporterEnabled()) { 372 if (breakpad::IsCrashReporterEnabled()) {
373 f = breakpad::CrashDumpManager::GetInstance()->CreateMinidumpFile( 373 f = breakpad::CrashDumpManager::GetInstance()->CreateMinidumpFile(
374 child_process_id); 374 child_process_id);
375 if (!f.IsValid()) { 375 if (!f.IsValid()) {
376 LOG(ERROR) << "Failed to create file for minidump, crash reporting will " 376 LOG(ERROR) << "Failed to create file for minidump, crash reporting will "
377 << "be disabled for this process."; 377 << "be disabled for this process.";
378 } else { 378 } else {
379 mappings->push_back( 379 mappings->Transfer(kAndroidMinidumpDescriptor,
380 FileDescriptorInfo(kAndroidMinidumpDescriptor, 380 base::ScopedFD(f.TakePlatformFile()));
381 base::FileDescriptor(f.Pass())));
382 } 381 }
383 } 382 }
384 #else // !defined(OS_ANDROID) 383 #else // !defined(OS_ANDROID)
385 int crash_signal_fd = GetCrashSignalFD(command_line); 384 int crash_signal_fd = GetCrashSignalFD(command_line);
386 if (crash_signal_fd >= 0) { 385 if (crash_signal_fd >= 0) {
387 mappings->push_back(FileDescriptorInfo( 386 mappings->Share(kCrashDumpSignal, crash_signal_fd);
388 kCrashDumpSignal, base::FileDescriptor(crash_signal_fd, false)));
389 } 387 }
390 #endif // defined(OS_ANDROID) 388 #endif // defined(OS_ANDROID)
391 } 389 }
392 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) 390 #endif // defined(OS_POSIX) && !defined(OS_MACOSX)
393 391
394 #if defined(OS_WIN) 392 #if defined(OS_WIN)
395 void ShellContentBrowserClient::PreSpawnRenderer(sandbox::TargetPolicy* policy, 393 void ShellContentBrowserClient::PreSpawnRenderer(sandbox::TargetPolicy* policy,
396 bool* success) { 394 bool* success) {
397 // Add sideloaded font files for testing. See also DIR_WINDOWS_FONTS 395 // Add sideloaded font files for testing. See also DIR_WINDOWS_FONTS
398 // addition in |StartSandboxedProcess|. 396 // addition in |StartSandboxedProcess|.
(...skipping 24 matching lines...) Expand all
423 ShellBrowserContext* 421 ShellBrowserContext*
424 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( 422 ShellContentBrowserClient::ShellBrowserContextForBrowserContext(
425 BrowserContext* content_browser_context) { 423 BrowserContext* content_browser_context) {
426 if (content_browser_context == browser_context()) 424 if (content_browser_context == browser_context())
427 return browser_context(); 425 return browser_context();
428 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); 426 DCHECK_EQ(content_browser_context, off_the_record_browser_context());
429 return off_the_record_browser_context(); 427 return off_the_record_browser_context();
430 } 428 }
431 429
432 } // namespace content 430 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698