OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_IMAGE_DECODER_H_ | 5 #ifndef CHROME_BROWSER_IMAGE_DECODER_H_ |
6 #define CHROME_BROWSER_IMAGE_DECODER_H_ | 6 #define CHROME_BROWSER_IMAGE_DECODER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 static void Cancel(ImageRequest* image_request); | 78 static void Cancel(ImageRequest* image_request); |
79 | 79 |
80 private: | 80 private: |
81 friend struct base::DefaultLazyInstanceTraits<ImageDecoder>; | 81 friend struct base::DefaultLazyInstanceTraits<ImageDecoder>; |
82 | 82 |
83 ImageDecoder(); | 83 ImageDecoder(); |
84 // It's a reference counted object, so destructor is private. | 84 // It's a reference counted object, so destructor is private. |
85 ~ImageDecoder() override; | 85 ~ImageDecoder() override; |
86 | 86 |
87 // Sends a request to the sandboxed process to decode the image. Starts | 87 // Sends a request to the sandboxed process to decode the image. Starts |
88 // batch mode if necessary. | 88 // batch mode if necessary. If the utility process fails to start, |
| 89 // an OnDecodeImageFailed task is posted to image_request's |task_runner_|. |
89 void DecodeImageInSandbox(ImageRequest* image_request, | 90 void DecodeImageInSandbox(ImageRequest* image_request, |
90 const std::vector<unsigned char>& image_data, | 91 const std::vector<unsigned char>& image_data, |
91 ImageCodec image_codec, | 92 ImageCodec image_codec, |
92 bool shrink_to_fit); | 93 bool shrink_to_fit); |
93 | 94 |
94 void CancelImpl(ImageRequest* image_request); | 95 void CancelImpl(ImageRequest* image_request); |
95 | 96 |
96 using RequestMap = std::map<int, ImageRequest*>; | 97 using RequestMap = std::map<int, ImageRequest*>; |
97 | 98 |
98 // Starts UtilityProcessHost in batch mode and starts |batch_mode_timer_|. | 99 // Starts UtilityProcessHost in batch mode and starts |batch_mode_timer_|. |
| 100 // If the utility process fails to start, the method resets |
| 101 // |utility_process_host_| and returns. |
99 void StartBatchMode(); | 102 void StartBatchMode(); |
100 | 103 |
101 // Stops batch mode if no requests have come in since | 104 // Stops batch mode if no requests have come in since |
102 // kBatchModeTimeoutSeconds. | 105 // kBatchModeTimeoutSeconds. |
103 void StopBatchMode(); | 106 void StopBatchMode(); |
104 | 107 |
105 // Overidden from UtilityProcessHostClient. | 108 // Overidden from UtilityProcessHostClient. |
106 bool OnMessageReceived(const IPC::Message& message) override; | 109 bool OnMessageReceived(const IPC::Message& message) override; |
107 | 110 |
108 // IPC message handlers. | 111 // IPC message handlers. |
(...skipping 15 matching lines...) Expand all Loading... |
124 // Calls StopBatchMode after kBatchModeTimeoutSeconds have elapsed. | 127 // Calls StopBatchMode after kBatchModeTimeoutSeconds have elapsed. |
125 base::RepeatingTimer<ImageDecoder> batch_mode_timer_; | 128 base::RepeatingTimer<ImageDecoder> batch_mode_timer_; |
126 | 129 |
127 // The time Start was last called. | 130 // The time Start was last called. |
128 base::TimeTicks last_request_; | 131 base::TimeTicks last_request_; |
129 | 132 |
130 DISALLOW_COPY_AND_ASSIGN(ImageDecoder); | 133 DISALLOW_COPY_AND_ASSIGN(ImageDecoder); |
131 }; | 134 }; |
132 | 135 |
133 #endif // CHROME_BROWSER_IMAGE_DECODER_H_ | 136 #endif // CHROME_BROWSER_IMAGE_DECODER_H_ |
OLD | NEW |