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 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_MEDIA_METADATA_PARSER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_MEDIA_METADATA_PARSER_H_ |
6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_MEDIA_METADATA_PARSER_H_ | 6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_MEDIA_METADATA_PARSER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 void Start(const DoneCallback& callback); | 46 void Start(const DoneCallback& callback); |
47 | 47 |
48 private: | 48 private: |
49 enum ParserState { | 49 enum ParserState { |
50 INITIAL_STATE, | 50 INITIAL_STATE, |
51 STARTED_PARSING_STATE, | 51 STARTED_PARSING_STATE, |
52 FINISHED_PARSING_STATE, | 52 FINISHED_PARSING_STATE, |
53 }; | 53 }; |
54 | 54 |
55 // Private because content::UtilityProcessHostClient is ref-counted. | 55 // Private because content::UtilityProcessHostClient is ref-counted. |
56 virtual ~SafeMediaMetadataParser(); | 56 ~SafeMediaMetadataParser() override; |
57 | 57 |
58 // Launches the utility process. Must run on the IO thread. | 58 // Launches the utility process. Must run on the IO thread. |
59 void StartWorkOnIOThread(const DoneCallback& callback); | 59 void StartWorkOnIOThread(const DoneCallback& callback); |
60 | 60 |
61 // Notification from the utility process when it finishes parsing metadata. | 61 // Notification from the utility process when it finishes parsing metadata. |
62 // Runs on the IO thread. | 62 // Runs on the IO thread. |
63 void OnParseMediaMetadataFinished( | 63 void OnParseMediaMetadataFinished( |
64 bool parse_success, const base::DictionaryValue& metadata_dictionary, | 64 bool parse_success, const base::DictionaryValue& metadata_dictionary, |
65 const std::vector<AttachedImage>& attached_images); | 65 const std::vector<AttachedImage>& attached_images); |
66 | 66 |
67 // Sequence of functions that bounces from the IO thread to the UI thread to | 67 // Sequence of functions that bounces from the IO thread to the UI thread to |
68 // read the blob data, then sends the data back to the utility process. | 68 // read the blob data, then sends the data back to the utility process. |
69 void OnUtilityProcessRequestBlobBytes(int64 request_id, int64 byte_start, | 69 void OnUtilityProcessRequestBlobBytes(int64 request_id, int64 byte_start, |
70 int64 length); | 70 int64 length); |
71 void StartBlobReaderOnUIThread(int64 request_id, int64 byte_start, | 71 void StartBlobReaderOnUIThread(int64 request_id, int64 byte_start, |
72 int64 length); | 72 int64 length); |
73 void OnBlobReaderDoneOnUIThread(int64 request_id, | 73 void OnBlobReaderDoneOnUIThread(int64 request_id, |
74 scoped_ptr<std::string> data, | 74 scoped_ptr<std::string> data, |
75 int64 /* blob_total_size */); | 75 int64 /* blob_total_size */); |
76 void FinishRequestBlobBytes(int64 request_id, scoped_ptr<std::string> data); | 76 void FinishRequestBlobBytes(int64 request_id, scoped_ptr<std::string> data); |
77 | 77 |
78 // UtilityProcessHostClient implementation. | 78 // UtilityProcessHostClient implementation. |
79 // Runs on the IO thread. | 79 // Runs on the IO thread. |
80 virtual void OnProcessCrashed(int exit_code) override; | 80 void OnProcessCrashed(int exit_code) override; |
81 virtual bool OnMessageReceived(const IPC::Message& message) override; | 81 bool OnMessageReceived(const IPC::Message& message) override; |
82 | 82 |
83 // All member variables are only accessed on the IO thread. | 83 // All member variables are only accessed on the IO thread. |
84 Profile* const profile_; | 84 Profile* const profile_; |
85 const std::string blob_uuid_; | 85 const std::string blob_uuid_; |
86 const int64 blob_size_; | 86 const int64 blob_size_; |
87 const std::string mime_type_; | 87 const std::string mime_type_; |
88 bool get_attached_images_; | 88 bool get_attached_images_; |
89 | 89 |
90 DoneCallback callback_; | 90 DoneCallback callback_; |
91 | 91 |
92 base::WeakPtr<content::UtilityProcessHost> utility_process_host_; | 92 base::WeakPtr<content::UtilityProcessHost> utility_process_host_; |
93 | 93 |
94 // Verifies the messages from the utility process came at the right time. | 94 // Verifies the messages from the utility process came at the right time. |
95 // Initialized on the UI thread, but only accessed on the IO thread. | 95 // Initialized on the UI thread, but only accessed on the IO thread. |
96 ParserState parser_state_; | 96 ParserState parser_state_; |
97 | 97 |
98 DISALLOW_COPY_AND_ASSIGN(SafeMediaMetadataParser); | 98 DISALLOW_COPY_AND_ASSIGN(SafeMediaMetadataParser); |
99 }; | 99 }; |
100 | 100 |
101 } // namespace metadata | 101 } // namespace metadata |
102 | 102 |
103 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_MEDIA_METADATA_PARSER_H_ | 103 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_MEDIA_METADATA_PARSER_H_ |
OLD | NEW |