| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 private: | 53 private: |
| 54 enum ParserState { | 54 enum ParserState { |
| 55 INITIAL_STATE, | 55 INITIAL_STATE, |
| 56 PINGED_UTILITY_PROCESS_STATE, | 56 PINGED_UTILITY_PROCESS_STATE, |
| 57 STARTED_PARSING_STATE, | 57 STARTED_PARSING_STATE, |
| 58 FINISHED_PARSING_STATE, | 58 FINISHED_PARSING_STATE, |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 // content::UtilityProcessHostClient is ref-counted. | 61 // content::UtilityProcessHostClient is ref-counted. |
| 62 virtual ~SafeIAppsLibraryParser(); | 62 ~SafeIAppsLibraryParser() override; |
| 63 | 63 |
| 64 // Posts a task to start the XML parsing in the utility process. | 64 // Posts a task to start the XML parsing in the utility process. |
| 65 void Start(); | 65 void Start(); |
| 66 | 66 |
| 67 // Launches the utility process. Must run on the IO thread. | 67 // Launches the utility process. Must run on the IO thread. |
| 68 void StartProcessOnIOThread(); | 68 void StartProcessOnIOThread(); |
| 69 | 69 |
| 70 // Notification that the utility process is running, and we can now get its | 70 // Notification that the utility process is running, and we can now get its |
| 71 // process handle. | 71 // process handle. |
| 72 // Runs on the IO thread. | 72 // Runs on the IO thread. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 84 | 84 |
| 85 // Sets |parser_state_| in case the library XML file cannot be opened. | 85 // Sets |parser_state_| in case the library XML file cannot be opened. |
| 86 // Runs on the IO thread. | 86 // Runs on the IO thread. |
| 87 void OnOpenLibraryFileFailed(); | 87 void OnOpenLibraryFileFailed(); |
| 88 | 88 |
| 89 // Communicates an error to the callback given to the constructor. | 89 // Communicates an error to the callback given to the constructor. |
| 90 void OnError(); | 90 void OnError(); |
| 91 | 91 |
| 92 // UtilityProcessHostClient implementation. | 92 // UtilityProcessHostClient implementation. |
| 93 // Runs on the IO thread. | 93 // Runs on the IO thread. |
| 94 virtual void OnProcessCrashed(int exit_code) override; | 94 void OnProcessCrashed(int exit_code) override; |
| 95 virtual bool OnMessageReceived(const IPC::Message& message) override; | 95 bool OnMessageReceived(const IPC::Message& message) override; |
| 96 | 96 |
| 97 base::FilePath library_file_path_; | 97 base::FilePath library_file_path_; |
| 98 | 98 |
| 99 // Once we have opened the file, we store the handle so that we can use it | 99 // Once we have opened the file, we store the handle so that we can use it |
| 100 // once the utility process has launched. | 100 // once the utility process has launched. |
| 101 base::File library_file_; | 101 base::File library_file_; |
| 102 | 102 |
| 103 // Only accessed on the IO thread. | 103 // Only accessed on the IO thread. |
| 104 base::WeakPtr<content::UtilityProcessHost> utility_process_host_; | 104 base::WeakPtr<content::UtilityProcessHost> utility_process_host_; |
| 105 | 105 |
| 106 // Only accessed on the Media Task Runner. | 106 // Only accessed on the Media Task Runner. |
| 107 ITunesParserCallback itunes_callback_; | 107 ITunesParserCallback itunes_callback_; |
| 108 | 108 |
| 109 // Only accessed on the Media Task Runner. | 109 // Only accessed on the Media Task Runner. |
| 110 IPhotoParserCallback iphoto_callback_; | 110 IPhotoParserCallback iphoto_callback_; |
| 111 | 111 |
| 112 // Verifies the messages from the utility process came at the right time. | 112 // Verifies the messages from the utility process came at the right time. |
| 113 // Initialized on the Media Task Runner, but only accessed on the IO thread. | 113 // Initialized on the Media Task Runner, but only accessed on the IO thread. |
| 114 ParserState parser_state_; | 114 ParserState parser_state_; |
| 115 | 115 |
| 116 DISALLOW_COPY_AND_ASSIGN(SafeIAppsLibraryParser); | 116 DISALLOW_COPY_AND_ASSIGN(SafeIAppsLibraryParser); |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 } // namespace iapps | 119 } // namespace iapps |
| 120 | 120 |
| 121 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_IAPPS_LIBRARY_PARSER_H_ | 121 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_IAPPS_LIBRARY_PARSER_H_ |
| OLD | NEW |