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

Side by Side Diff: chrome/utility/extensions/extensions_handler.cc

Issue 2639503002: Convert utility process CheckMediaFile IPC to mojo (Closed)
Patch Set: Removed unused #include files, add TODO. Created 3 years, 11 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
« no previous file with comments | « chrome/common/extensions/media_parser.mojom ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/utility/extensions/extensions_handler.h" 5 #include "chrome/utility/extensions/extensions_handler.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 28 matching lines...) Expand all
39 39
40 #if defined(OS_WIN) || defined(OS_MACOSX) 40 #if defined(OS_WIN) || defined(OS_MACOSX)
41 #include "chrome/utility/media_galleries/iapps_xml_utils.h" 41 #include "chrome/utility/media_galleries/iapps_xml_utils.h"
42 #include "chrome/utility/media_galleries/itunes_library_parser.h" 42 #include "chrome/utility/media_galleries/itunes_library_parser.h"
43 #include "chrome/utility/media_galleries/picasa_album_table_reader.h" 43 #include "chrome/utility/media_galleries/picasa_album_table_reader.h"
44 #include "chrome/utility/media_galleries/picasa_albums_indexer.h" 44 #include "chrome/utility/media_galleries/picasa_albums_indexer.h"
45 #endif // defined(OS_WIN) || defined(OS_MACOSX) 45 #endif // defined(OS_WIN) || defined(OS_MACOSX)
46 46
47 namespace { 47 namespace {
48 48
49 bool Send(IPC::Message* message) {
50 return content::UtilityThread::Get()->Send(message);
51 }
52
53 void ReleaseProcessIfNeeded() { 49 void ReleaseProcessIfNeeded() {
54 content::UtilityThread::Get()->ReleaseProcessIfNeeded(); 50 content::UtilityThread::Get()->ReleaseProcessIfNeeded();
55 } 51 }
56 52
57 class MediaParserImpl : public extensions::mojom::MediaParser { 53 class MediaParserImpl : public extensions::mojom::MediaParser {
58 public: 54 public:
59 static void Create(ChromeContentUtilityClient* utility_client, 55 static void Create(ChromeContentUtilityClient* utility_client,
60 extensions::mojom::MediaParserRequest request) { 56 extensions::mojom::MediaParserRequest request) {
61 mojo::MakeStrongBinding(base::MakeUnique<MediaParserImpl>(utility_client), 57 mojo::MakeStrongBinding(base::MakeUnique<MediaParserImpl>(utility_client),
62 std::move(request)); 58 std::move(request));
(...skipping 21 matching lines...) Expand all
84 80
85 static void ParseMediaMetadataDone( 81 static void ParseMediaMetadataDone(
86 const ParseMediaMetadataCallback& callback, 82 const ParseMediaMetadataCallback& callback,
87 metadata::MediaMetadataParser* /* parser */, 83 metadata::MediaMetadataParser* /* parser */,
88 const extensions::api::media_galleries::MediaMetadata& metadata, 84 const extensions::api::media_galleries::MediaMetadata& metadata,
89 const std::vector<metadata::AttachedImage>& attached_images) { 85 const std::vector<metadata::AttachedImage>& attached_images) {
90 callback.Run(true, metadata.ToValue(), attached_images); 86 callback.Run(true, metadata.ToValue(), attached_images);
91 ReleaseProcessIfNeeded(); 87 ReleaseProcessIfNeeded();
92 } 88 }
93 89
90 void CheckMediaFile(base::TimeDelta decode_time,
91 base::File file,
92 const CheckMediaFileCallback& callback) override {
93 #if !defined(MEDIA_DISABLE_FFMPEG)
94 media::MediaFileChecker checker(std::move(file));
95 callback.Run(checker.Start(decode_time));
96 #else
97 callback.Run(false);
98 #endif
99 ReleaseProcessIfNeeded();
100 }
101
94 ChromeContentUtilityClient* const utility_client_; 102 ChromeContentUtilityClient* const utility_client_;
95 103
96 DISALLOW_COPY_AND_ASSIGN(MediaParserImpl); 104 DISALLOW_COPY_AND_ASSIGN(MediaParserImpl);
97 }; 105 };
98 106
99 #if defined(OS_WIN) 107 #if defined(OS_WIN)
100 class WiFiCredentialsGetterImpl 108 class WiFiCredentialsGetterImpl
101 : public extensions::mojom::WiFiCredentialsGetter { 109 : public extensions::mojom::WiFiCredentialsGetter {
102 public: 110 public:
103 WiFiCredentialsGetterImpl() = default; 111 WiFiCredentialsGetterImpl() = default;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 #endif 174 #endif
167 return; 175 return;
168 } 176 }
169 177
170 registry->AddInterface(base::Bind(&MediaParserImpl::Create, utility_client)); 178 registry->AddInterface(base::Bind(&MediaParserImpl::Create, utility_client));
171 } 179 }
172 180
173 bool ExtensionsHandler::OnMessageReceived(const IPC::Message& message) { 181 bool ExtensionsHandler::OnMessageReceived(const IPC::Message& message) {
174 bool handled = true; 182 bool handled = true;
175 IPC_BEGIN_MESSAGE_MAP(ExtensionsHandler, message) 183 IPC_BEGIN_MESSAGE_MAP(ExtensionsHandler, message)
176 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CheckMediaFile, OnCheckMediaFile)
177
178 #if defined(OS_WIN) 184 #if defined(OS_WIN)
179 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesPrefXml, 185 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesPrefXml,
180 OnParseITunesPrefXml) 186 OnParseITunesPrefXml)
181 #endif // defined(OS_WIN) 187 #endif // defined(OS_WIN)
182 188
183 #if defined(OS_WIN) || defined(OS_MACOSX) 189 #if defined(OS_WIN) || defined(OS_MACOSX)
184 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesLibraryXmlFile, 190 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesLibraryXmlFile,
185 OnParseITunesLibraryXmlFile) 191 OnParseITunesLibraryXmlFile)
186 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParsePicasaPMPDatabase, 192 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParsePicasaPMPDatabase,
187 OnParsePicasaPMPDatabase) 193 OnParsePicasaPMPDatabase)
188 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_IndexPicasaAlbumsContents, 194 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_IndexPicasaAlbumsContents,
189 OnIndexPicasaAlbumsContents) 195 OnIndexPicasaAlbumsContents)
190 #endif // defined(OS_WIN) || defined(OS_MACOSX) 196 #endif // defined(OS_WIN) || defined(OS_MACOSX)
191 197
192 IPC_MESSAGE_UNHANDLED(handled = false) 198 IPC_MESSAGE_UNHANDLED(handled = false)
193 IPC_END_MESSAGE_MAP() 199 IPC_END_MESSAGE_MAP()
194 200
195 return handled || utility_handler_.OnMessageReceived(message); 201 return handled || utility_handler_.OnMessageReceived(message);
196 } 202 }
197 203
198 void ExtensionsHandler::OnCheckMediaFile(
199 int64_t milliseconds_of_decoding,
200 const IPC::PlatformFileForTransit& media_file) {
201 #if !defined(MEDIA_DISABLE_FFMPEG)
202 media::MediaFileChecker checker(
203 IPC::PlatformFileForTransitToFile(media_file));
204 const bool check_success = checker.Start(
205 base::TimeDelta::FromMilliseconds(milliseconds_of_decoding));
206 Send(new ChromeUtilityHostMsg_CheckMediaFile_Finished(check_success));
207 #else
208 Send(new ChromeUtilityHostMsg_CheckMediaFile_Finished(false));
209 #endif
210 ReleaseProcessIfNeeded();
211 }
212
213 #if defined(OS_WIN) 204 #if defined(OS_WIN)
214 void ExtensionsHandler::OnParseITunesPrefXml( 205 void ExtensionsHandler::OnParseITunesPrefXml(
215 const std::string& itunes_xml_data) { 206 const std::string& itunes_xml_data) {
216 base::FilePath library_path( 207 base::FilePath library_path(
217 itunes::FindLibraryLocationInPrefXml(itunes_xml_data)); 208 itunes::FindLibraryLocationInPrefXml(itunes_xml_data));
218 Send(new ChromeUtilityHostMsg_GotITunesDirectory(library_path)); 209 content::UtilityThread::Get()->Send(
210 new ChromeUtilityHostMsg_GotITunesDirectory(library_path));
219 ReleaseProcessIfNeeded(); 211 ReleaseProcessIfNeeded();
220 } 212 }
221 #endif // defined(OS_WIN) 213 #endif // defined(OS_WIN)
222 214
223 #if defined(OS_WIN) || defined(OS_MACOSX) 215 #if defined(OS_WIN) || defined(OS_MACOSX)
224 void ExtensionsHandler::OnParseITunesLibraryXmlFile( 216 void ExtensionsHandler::OnParseITunesLibraryXmlFile(
225 const IPC::PlatformFileForTransit& itunes_library_file) { 217 const IPC::PlatformFileForTransit& itunes_library_file) {
226 itunes::ITunesLibraryParser parser; 218 itunes::ITunesLibraryParser parser;
227 base::File file = IPC::PlatformFileForTransitToFile(itunes_library_file); 219 base::File file = IPC::PlatformFileForTransitToFile(itunes_library_file);
228 bool result = parser.Parse(iapps::ReadFileAsString(std::move(file))); 220 bool result = parser.Parse(iapps::ReadFileAsString(std::move(file)));
229 Send(new ChromeUtilityHostMsg_GotITunesLibrary(result, parser.library())); 221 content::UtilityThread::Get()->Send(
222 new ChromeUtilityHostMsg_GotITunesLibrary(result, parser.library()));
230 ReleaseProcessIfNeeded(); 223 ReleaseProcessIfNeeded();
231 } 224 }
232 225
233 void ExtensionsHandler::OnParsePicasaPMPDatabase( 226 void ExtensionsHandler::OnParsePicasaPMPDatabase(
234 const picasa::AlbumTableFilesForTransit& album_table_files) { 227 const picasa::AlbumTableFilesForTransit& album_table_files) {
235 picasa::AlbumTableFiles files; 228 picasa::AlbumTableFiles files;
236 files.indicator_file = 229 files.indicator_file =
237 IPC::PlatformFileForTransitToFile(album_table_files.indicator_file); 230 IPC::PlatformFileForTransitToFile(album_table_files.indicator_file);
238 files.category_file = 231 files.category_file =
239 IPC::PlatformFileForTransitToFile(album_table_files.category_file); 232 IPC::PlatformFileForTransitToFile(album_table_files.category_file);
240 files.date_file = 233 files.date_file =
241 IPC::PlatformFileForTransitToFile(album_table_files.date_file); 234 IPC::PlatformFileForTransitToFile(album_table_files.date_file);
242 files.filename_file = 235 files.filename_file =
243 IPC::PlatformFileForTransitToFile(album_table_files.filename_file); 236 IPC::PlatformFileForTransitToFile(album_table_files.filename_file);
244 files.name_file = 237 files.name_file =
245 IPC::PlatformFileForTransitToFile(album_table_files.name_file); 238 IPC::PlatformFileForTransitToFile(album_table_files.name_file);
246 files.token_file = 239 files.token_file =
247 IPC::PlatformFileForTransitToFile(album_table_files.token_file); 240 IPC::PlatformFileForTransitToFile(album_table_files.token_file);
248 files.uid_file = 241 files.uid_file =
249 IPC::PlatformFileForTransitToFile(album_table_files.uid_file); 242 IPC::PlatformFileForTransitToFile(album_table_files.uid_file);
250 243
251 picasa::PicasaAlbumTableReader reader(std::move(files)); 244 picasa::PicasaAlbumTableReader reader(std::move(files));
252 bool parse_success = reader.Init(); 245 bool parse_success = reader.Init();
253 Send(new ChromeUtilityHostMsg_ParsePicasaPMPDatabase_Finished( 246 content::UtilityThread::Get()->Send(
254 parse_success, reader.albums(), reader.folders())); 247 new ChromeUtilityHostMsg_ParsePicasaPMPDatabase_Finished(
248 parse_success, reader.albums(), reader.folders()));
255 ReleaseProcessIfNeeded(); 249 ReleaseProcessIfNeeded();
256 } 250 }
257 251
258 void ExtensionsHandler::OnIndexPicasaAlbumsContents( 252 void ExtensionsHandler::OnIndexPicasaAlbumsContents(
259 const picasa::AlbumUIDSet& album_uids, 253 const picasa::AlbumUIDSet& album_uids,
260 const std::vector<picasa::FolderINIContents>& folders_inis) { 254 const std::vector<picasa::FolderINIContents>& folders_inis) {
261 picasa::PicasaAlbumsIndexer indexer(album_uids); 255 picasa::PicasaAlbumsIndexer indexer(album_uids);
262 indexer.ParseFolderINI(folders_inis); 256 indexer.ParseFolderINI(folders_inis);
263 257 content::UtilityThread::Get()->Send(
264 Send(new ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished( 258 new ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished(
265 indexer.albums_images())); 259 indexer.albums_images()));
266 ReleaseProcessIfNeeded(); 260 ReleaseProcessIfNeeded();
267 } 261 }
268 #endif // defined(OS_WIN) || defined(OS_MACOSX) 262 #endif // defined(OS_WIN) || defined(OS_MACOSX)
269 263
270 } // namespace extensions 264 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/media_parser.mojom ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698