| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_IAPPS_LIBRARY_PARSER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_IAPPS_LIBRARY_PARSER_H_ |
| 6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_IAPPS_LIBRARY_PARSER_H_ | 6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_IAPPS_LIBRARY_PARSER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 SafeIAppsLibraryParser(); | 41 SafeIAppsLibraryParser(); |
| 42 | 42 |
| 43 // Start the parse of the iTunes library file. | 43 // Start the parse of the iTunes library file. |
| 44 void ParseITunesLibrary(const base::FilePath& library_file, | 44 void ParseITunesLibrary(const base::FilePath& library_file, |
| 45 const ITunesParserCallback& callback); | 45 const ITunesParserCallback& callback); |
| 46 | 46 |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 enum ParserState { | 49 enum ParserState { |
| 50 INITIAL_STATE, | 50 INITIAL_STATE, |
| 51 PINGED_UTILITY_PROCESS_STATE, | |
| 52 STARTED_PARSING_STATE, | 51 STARTED_PARSING_STATE, |
| 53 FINISHED_PARSING_STATE, | 52 FINISHED_PARSING_STATE, |
| 54 }; | 53 }; |
| 55 | 54 |
| 56 // content::UtilityProcessHostClient is ref-counted. | 55 // content::UtilityProcessHostClient is ref-counted. |
| 57 ~SafeIAppsLibraryParser() override; | 56 ~SafeIAppsLibraryParser() override; |
| 58 | 57 |
| 59 // Posts a task to start the XML parsing in the utility process. | 58 // Posts a task to start the XML parsing in the utility process. |
| 60 void Start(); | 59 void Start(); |
| 61 | 60 |
| 62 // Launches the utility process. Must run on the IO thread. | 61 // Launches the utility process. Must run on the IO thread. |
| 63 void StartProcessOnIOThread(); | 62 void StartProcessOnIOThread(); |
| 64 | 63 |
| 65 // Notification that the utility process is running, and we can now get its | |
| 66 // process handle. | |
| 67 // Runs on the IO thread. | |
| 68 void OnUtilityProcessStarted(); | |
| 69 | |
| 70 // Notification from the utility process when it finishes parsing the | 64 // Notification from the utility process when it finishes parsing the |
| 71 // iTunes XML. Runs on the IO thread. | 65 // iTunes XML. Runs on the IO thread. |
| 72 void OnGotITunesLibrary(bool result, const itunes::parser::Library& library); | 66 void OnGotITunesLibrary(bool result, const itunes::parser::Library& library); |
| 73 | 67 |
| 74 // Sets |parser_state_| in case the library XML file cannot be opened. | 68 // Sets |parser_state_| in case the library XML file cannot be opened. |
| 75 // Runs on the IO thread. | 69 // Runs on the IO thread. |
| 76 void OnOpenLibraryFileFailed(); | 70 void OnOpenLibraryFileFailed(); |
| 77 | 71 |
| 78 // Communicates an error to the callback given to the constructor. | 72 // Communicates an error to the callback given to the constructor. |
| 79 void OnError(); | 73 void OnError(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 98 // Verifies the messages from the utility process came at the right time. | 92 // Verifies the messages from the utility process came at the right time. |
| 99 // Initialized on the Media Task Runner, but only accessed on the IO thread. | 93 // Initialized on the Media Task Runner, but only accessed on the IO thread. |
| 100 ParserState parser_state_; | 94 ParserState parser_state_; |
| 101 | 95 |
| 102 DISALLOW_COPY_AND_ASSIGN(SafeIAppsLibraryParser); | 96 DISALLOW_COPY_AND_ASSIGN(SafeIAppsLibraryParser); |
| 103 }; | 97 }; |
| 104 | 98 |
| 105 } // namespace iapps | 99 } // namespace iapps |
| 106 | 100 |
| 107 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_IAPPS_LIBRARY_PARSER_H_ | 101 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_IAPPS_LIBRARY_PARSER_H_ |
| OLD | NEW |