OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chromecast/browser/cast_content_browser_client.h" | 5 #include "chromecast/browser/cast_content_browser_client.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
31 #include "content/public/browser/certificate_request_result_type.h" | 31 #include "content/public/browser/certificate_request_result_type.h" |
32 #include "content/public/browser/client_certificate_delegate.h" | 32 #include "content/public/browser/client_certificate_delegate.h" |
33 #include "content/public/browser/render_process_host.h" | 33 #include "content/public/browser/render_process_host.h" |
34 #include "content/public/browser/resource_dispatcher_host.h" | 34 #include "content/public/browser/resource_dispatcher_host.h" |
35 #include "content/public/browser/web_contents.h" | 35 #include "content/public/browser/web_contents.h" |
36 #include "content/public/common/content_descriptors.h" | 36 #include "content/public/common/content_descriptors.h" |
37 #include "content/public/common/content_switches.h" | 37 #include "content/public/common/content_switches.h" |
38 #include "content/public/common/url_constants.h" | 38 #include "content/public/common/url_constants.h" |
39 #include "content/public/common/web_preferences.h" | 39 #include "content/public/common/web_preferences.h" |
40 #include "gin/v8_initializer.h" | |
41 #include "media/audio/audio_manager_factory.h" | 40 #include "media/audio/audio_manager_factory.h" |
42 #include "net/ssl/ssl_cert_request_info.h" | 41 #include "net/ssl/ssl_cert_request_info.h" |
43 #include "net/url_request/url_request_context_getter.h" | 42 #include "net/url_request/url_request_context_getter.h" |
44 #include "ui/gl/gl_switches.h" | 43 #include "ui/gl/gl_switches.h" |
45 | 44 |
46 #if defined(OS_ANDROID) | 45 #if defined(OS_ANDROID) |
47 #include "components/crash/browser/crash_dump_manager_android.h" | 46 #include "components/crash/browser/crash_dump_manager_android.h" |
48 #include "components/external_video_surface/browser/android/external_video_surfa
ce_container_impl.h" | 47 #include "components/external_video_surface/browser/android/external_video_surfa
ce_container_impl.h" |
49 #endif // defined(OS_ANDROID) | 48 #endif // defined(OS_ANDROID) |
50 | 49 |
51 namespace chromecast { | 50 namespace chromecast { |
52 namespace shell { | 51 namespace shell { |
53 | 52 |
54 CastContentBrowserClient::CastContentBrowserClient() | 53 CastContentBrowserClient::CastContentBrowserClient() |
55 : v8_natives_fd_(-1), | 54 : url_request_context_factory_(new URLRequestContextFactory()) { |
56 v8_snapshot_fd_(-1), | |
57 url_request_context_factory_(new URLRequestContextFactory()) { | |
58 } | 55 } |
59 | 56 |
60 CastContentBrowserClient::~CastContentBrowserClient() { | 57 CastContentBrowserClient::~CastContentBrowserClient() { |
61 content::BrowserThread::DeleteSoon( | 58 content::BrowserThread::DeleteSoon( |
62 content::BrowserThread::IO, | 59 content::BrowserThread::IO, |
63 FROM_HERE, | 60 FROM_HERE, |
64 url_request_context_factory_.release()); | 61 url_request_context_factory_.release()); |
65 } | 62 } |
66 | 63 |
67 content::BrowserMainParts* CastContentBrowserClient::CreateBrowserMainParts( | 64 content::BrowserMainParts* CastContentBrowserClient::CreateBrowserMainParts( |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 int render_process_id, | 304 int render_process_id, |
308 int opener_id, | 305 int opener_id, |
309 bool* no_javascript_access) { | 306 bool* no_javascript_access) { |
310 *no_javascript_access = true; | 307 *no_javascript_access = true; |
311 return false; | 308 return false; |
312 } | 309 } |
313 | 310 |
314 void CastContentBrowserClient::GetAdditionalMappedFilesForChildProcess( | 311 void CastContentBrowserClient::GetAdditionalMappedFilesForChildProcess( |
315 const base::CommandLine& command_line, | 312 const base::CommandLine& command_line, |
316 int child_process_id, | 313 int child_process_id, |
317 content::FileDescriptorInfo* mappings) { | 314 content::FileDescriptorInfo* mappings |
| 315 #if defined(OS_ANDROID) |
| 316 , std::map<int, base::MemoryMappedFile::Region>* regions |
| 317 #endif |
| 318 ) { |
318 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) | 319 #if defined(V8_USE_EXTERNAL_STARTUP_DATA) |
319 if (v8_natives_fd_.get() == -1 || v8_snapshot_fd_.get() == -1) { | 320 if (!v8_files_.IsLoaded()) { |
320 int v8_natives_fd = -1; | 321 gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_files_); |
321 int v8_snapshot_fd = -1; | |
322 if (gin::V8Initializer::OpenV8FilesForChildProcesses(&v8_natives_fd, | |
323 &v8_snapshot_fd)) { | |
324 v8_natives_fd_.reset(v8_natives_fd); | |
325 v8_snapshot_fd_.reset(v8_snapshot_fd); | |
326 } | |
327 } | 322 } |
328 DCHECK(v8_natives_fd_.get() != -1 && v8_snapshot_fd_.get() != -1); | 323 DCHECK(v8_files_.IsLoaded()); |
329 mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get()); | 324 mappings->Share(kV8NativesDataDescriptor, v8_files_.natives_fd.get()); |
330 mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get()); | 325 mappings->Share(kV8SnapshotDataDescriptor, v8_files_.snapshot_fd.get()); |
| 326 #if defined(OS_ANDROID) |
| 327 regions->insert( |
| 328 std::make_pair(kV8NativesDataDescriptor, v8_files_.natives_region)); |
| 329 regions->insert( |
| 330 std::make_pair(kV8SnapshotDataDescriptor, v8_files_.snapshot_region)); |
| 331 #endif // defined(OS_ANDROID) |
331 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 332 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
332 #if defined(OS_ANDROID) | 333 #if defined(OS_ANDROID) |
333 const int flags_open_read = base::File::FLAG_OPEN | base::File::FLAG_READ; | 334 const int flags_open_read = base::File::FLAG_OPEN | base::File::FLAG_READ; |
334 base::FilePath pak_file_path; | 335 base::FilePath pak_file_path; |
335 CHECK(PathService::Get(FILE_CAST_PAK, &pak_file_path)); | 336 CHECK(PathService::Get(FILE_CAST_PAK, &pak_file_path)); |
336 base::File pak_file(pak_file_path, flags_open_read); | 337 base::File pak_file(pak_file_path, flags_open_read); |
337 if (!pak_file.IsValid()) { | 338 if (!pak_file.IsValid()) { |
338 NOTREACHED() << "Failed to open file when creating renderer process: " | 339 NOTREACHED() << "Failed to open file when creating renderer process: " |
339 << "cast_shell.pak"; | 340 << "cast_shell.pak"; |
340 } | 341 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 process_type, dumps_path, false /* upload */); | 415 process_type, dumps_path, false /* upload */); |
415 // StartUploaderThread() even though upload is diferred. | 416 // StartUploaderThread() even though upload is diferred. |
416 // Breakpad-related memory is freed in the uploader thread. | 417 // Breakpad-related memory is freed in the uploader thread. |
417 crash_handler->StartUploaderThread(); | 418 crash_handler->StartUploaderThread(); |
418 return crash_handler; | 419 return crash_handler; |
419 } | 420 } |
420 #endif // !defined(OS_ANDROID) | 421 #endif // !defined(OS_ANDROID) |
421 | 422 |
422 } // namespace shell | 423 } // namespace shell |
423 } // namespace chromecast | 424 } // namespace chromecast |
OLD | NEW |