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

Side by Side Diff: chrome/browser/media_galleries/fileapi/safe_iapps_library_parser.cc

Issue 1885813002: Delete the utility process startup ping. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 8 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 "chrome/browser/media_galleries/fileapi/safe_iapps_library_parser.h" 5 #include "chrome/browser/media_galleries/fileapi/safe_iapps_library_parser.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" 10 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 void SafeIAppsLibraryParser::StartProcessOnIOThread() { 58 void SafeIAppsLibraryParser::StartProcessOnIOThread() {
59 DCHECK_CURRENTLY_ON(BrowserThread::IO); 59 DCHECK_CURRENTLY_ON(BrowserThread::IO);
60 DCHECK_EQ(INITIAL_STATE, parser_state_); 60 DCHECK_EQ(INITIAL_STATE, parser_state_);
61 61
62 scoped_refptr<base::SingleThreadTaskRunner> task_runner = 62 scoped_refptr<base::SingleThreadTaskRunner> task_runner =
63 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); 63 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
64 utility_process_host_ = 64 utility_process_host_ =
65 UtilityProcessHost::Create(this, task_runner.get())->AsWeakPtr(); 65 UtilityProcessHost::Create(this, task_runner.get())->AsWeakPtr();
66 utility_process_host_->SetName(l10n_util::GetStringUTF16( 66 utility_process_host_->SetName(l10n_util::GetStringUTF16(
67 IDS_UTILITY_PROCESS_MEDIA_LIBRARY_FILE_CHECKER_NAME)); 67 IDS_UTILITY_PROCESS_MEDIA_LIBRARY_FILE_CHECKER_NAME));
68 // Wait for the startup notification before sending the main IPC to the 68 utility_process_host_->Send(new ChromeUtilityMsg_ParseITunesLibraryXmlFile(
69 // utility process, so that we can dup the file handle. 69 IPC::TakePlatformFileForTransit(std::move(library_file_))));
70 utility_process_host_->Send(new ChromeUtilityMsg_StartupPing);
71 parser_state_ = PINGED_UTILITY_PROCESS_STATE;
72 }
73
74 void SafeIAppsLibraryParser::OnUtilityProcessStarted() {
75 DCHECK_CURRENTLY_ON(BrowserThread::IO);
76 if (parser_state_ != PINGED_UTILITY_PROCESS_STATE)
77 return;
78
79 if (utility_process_host_->GetData().handle == base::kNullProcessHandle) {
80 DLOG(ERROR) << "Child process handle is null";
81 OnError();
82 return;
83 }
84
85 if (!itunes_callback_.is_null()) {
86 utility_process_host_->Send(new ChromeUtilityMsg_ParseITunesLibraryXmlFile(
87 IPC::TakePlatformFileForTransit(std::move(library_file_))));
88 }
89 70
90 parser_state_ = STARTED_PARSING_STATE; 71 parser_state_ = STARTED_PARSING_STATE;
91 } 72 }
92 73
93 void SafeIAppsLibraryParser::OnGotITunesLibrary( 74 void SafeIAppsLibraryParser::OnGotITunesLibrary(
94 bool result, const itunes::parser::Library& library) { 75 bool result, const itunes::parser::Library& library) {
95 DCHECK_CURRENTLY_ON(BrowserThread::IO); 76 DCHECK_CURRENTLY_ON(BrowserThread::IO);
96 DCHECK(!itunes_callback_.is_null()); 77 DCHECK(!itunes_callback_.is_null());
97 78
98 if (parser_state_ != STARTED_PARSING_STATE) 79 if (parser_state_ != STARTED_PARSING_STATE)
(...skipping 17 matching lines...) Expand all
116 void SafeIAppsLibraryParser::OnError() { 97 void SafeIAppsLibraryParser::OnError() {
117 parser_state_ = FINISHED_PARSING_STATE; 98 parser_state_ = FINISHED_PARSING_STATE;
118 if (!itunes_callback_.is_null()) 99 if (!itunes_callback_.is_null())
119 OnGotITunesLibrary(false /* failed */, itunes::parser::Library()); 100 OnGotITunesLibrary(false /* failed */, itunes::parser::Library());
120 } 101 }
121 102
122 bool SafeIAppsLibraryParser::OnMessageReceived( 103 bool SafeIAppsLibraryParser::OnMessageReceived(
123 const IPC::Message& message) { 104 const IPC::Message& message) {
124 bool handled = true; 105 bool handled = true;
125 IPC_BEGIN_MESSAGE_MAP(SafeIAppsLibraryParser, message) 106 IPC_BEGIN_MESSAGE_MAP(SafeIAppsLibraryParser, message)
126 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ProcessStarted,
127 OnUtilityProcessStarted)
128 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_GotITunesLibrary, 107 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_GotITunesLibrary,
129 OnGotITunesLibrary) 108 OnGotITunesLibrary)
130 IPC_MESSAGE_UNHANDLED(handled = false) 109 IPC_MESSAGE_UNHANDLED(handled = false)
131 IPC_END_MESSAGE_MAP() 110 IPC_END_MESSAGE_MAP()
132 return handled; 111 return handled;
133 } 112 }
134 113
135 } // namespace iapps 114 } // namespace iapps
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698