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

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: Fixing windows build failure 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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 350
351 DevToolsManagerDelegate* 351 DevToolsManagerDelegate*
352 ShellContentBrowserClient::GetDevToolsManagerDelegate() { 352 ShellContentBrowserClient::GetDevToolsManagerDelegate() {
353 return new ShellDevToolsManagerDelegate(browser_context()); 353 return new ShellDevToolsManagerDelegate(browser_context());
354 } 354 }
355 355
356 #if defined(OS_POSIX) && !defined(OS_MACOSX) 356 #if defined(OS_POSIX) && !defined(OS_MACOSX)
357 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( 357 void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
358 const CommandLine& command_line, 358 const CommandLine& command_line,
359 int child_process_id, 359 int child_process_id,
360 std::vector<FileDescriptorInfo>* mappings) { 360 FileDescriptorInfo* mappings) {
361 #if defined(OS_ANDROID) 361 #if defined(OS_ANDROID)
362 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ; 362 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ;
363 base::FilePath pak_file; 363 base::FilePath pak_file;
364 bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file); 364 bool r = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_file);
365 CHECK(r); 365 CHECK(r);
366 pak_file = pak_file.Append(FILE_PATH_LITERAL("paks")); 366 pak_file = pak_file.Append(FILE_PATH_LITERAL("paks"));
367 pak_file = pak_file.Append(FILE_PATH_LITERAL("content_shell.pak")); 367 pak_file = pak_file.Append(FILE_PATH_LITERAL("content_shell.pak"));
368 368
369 base::File f(pak_file, flags); 369 base::File f(pak_file, flags);
370 if (!f.IsValid()) { 370 if (!f.IsValid()) {
371 NOTREACHED() << "Failed to open file when creating renderer process: " 371 NOTREACHED() << "Failed to open file when creating renderer process: "
372 << "content_shell.pak"; 372 << "content_shell.pak";
373 } 373 }
374 mappings->push_back( 374
375 FileDescriptorInfo(kShellPakDescriptor, base::FileDescriptor(f.Pass()))); 375 mappings->Transfer(kShellPakDescriptor, base::ScopedFD(f.TakePlatformFile()));
376 376
377 if (breakpad::IsCrashReporterEnabled()) { 377 if (breakpad::IsCrashReporterEnabled()) {
378 f = breakpad::CrashDumpManager::GetInstance()->CreateMinidumpFile( 378 f = breakpad::CrashDumpManager::GetInstance()->CreateMinidumpFile(
379 child_process_id); 379 child_process_id);
380 if (!f.IsValid()) { 380 if (!f.IsValid()) {
381 LOG(ERROR) << "Failed to create file for minidump, crash reporting will " 381 LOG(ERROR) << "Failed to create file for minidump, crash reporting will "
382 << "be disabled for this process."; 382 << "be disabled for this process.";
383 } else { 383 } else {
384 mappings->push_back( 384 mappings->Transfer(kAndroidMinidumpDescriptor,
385 FileDescriptorInfo(kAndroidMinidumpDescriptor, 385 base::ScopedFD(f.TakePlatformFile()));
386 base::FileDescriptor(f.Pass())));
387 } 386 }
388 } 387 }
389 #else // !defined(OS_ANDROID) 388 #else // !defined(OS_ANDROID)
390 int crash_signal_fd = GetCrashSignalFD(command_line); 389 int crash_signal_fd = GetCrashSignalFD(command_line);
391 if (crash_signal_fd >= 0) { 390 if (crash_signal_fd >= 0) {
392 mappings->push_back(FileDescriptorInfo( 391 mappings->Share(kCrashDumpSignal, crash_signal_fd);
393 kCrashDumpSignal, base::FileDescriptor(crash_signal_fd, false)));
394 } 392 }
395 #endif // defined(OS_ANDROID) 393 #endif // defined(OS_ANDROID)
396 } 394 }
397 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) 395 #endif // defined(OS_POSIX) && !defined(OS_MACOSX)
398 396
399 #if defined(OS_WIN) 397 #if defined(OS_WIN)
400 void ShellContentBrowserClient::PreSpawnRenderer(sandbox::TargetPolicy* policy, 398 void ShellContentBrowserClient::PreSpawnRenderer(sandbox::TargetPolicy* policy,
401 bool* success) { 399 bool* success) {
402 // Add sideloaded font files for testing. See also DIR_WINDOWS_FONTS 400 // Add sideloaded font files for testing. See also DIR_WINDOWS_FONTS
403 // addition in |StartSandboxedProcess|. 401 // addition in |StartSandboxedProcess|.
(...skipping 24 matching lines...) Expand all
428 ShellBrowserContext* 426 ShellBrowserContext*
429 ShellContentBrowserClient::ShellBrowserContextForBrowserContext( 427 ShellContentBrowserClient::ShellBrowserContextForBrowserContext(
430 BrowserContext* content_browser_context) { 428 BrowserContext* content_browser_context) {
431 if (content_browser_context == browser_context()) 429 if (content_browser_context == browser_context())
432 return browser_context(); 430 return browser_context();
433 DCHECK_EQ(content_browser_context, off_the_record_browser_context()); 431 DCHECK_EQ(content_browser_context, off_the_record_browser_context());
434 return off_the_record_browser_context(); 432 return off_the_record_browser_context();
435 } 433 }
436 434
437 } // namespace content 435 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698