| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_DATA_REDUCTION_PROXY_CONTENT_BROWSER_CONTENT_LOFI_UI_SERVICE_
H_ | 5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_CONTENT_BROWSER_CONTENT_LOFI_UI_SERVICE_
H_ |
| 6 #define COMPONENTS_DATA_REDUCTION_PROXY_CONTENT_BROWSER_CONTENT_LOFI_UI_SERVICE_
H_ | 6 #define COMPONENTS_DATA_REDUCTION_PROXY_CONTENT_BROWSER_CONTENT_LOFI_UI_SERVICE_
H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "components/data_reduction_proxy/core/common/lofi_ui_service.h" | 11 #include "components/data_reduction_proxy/core/common/lofi_ui_service.h" |
| 12 | 12 |
| 13 namespace base { | 13 namespace base { |
| 14 class SingleThreadTaskRunner; | 14 class SingleThreadTaskRunner; |
| 15 } | 15 } |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 class WebContents; | 18 class WebContents; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace net { | 21 namespace net { |
| 22 class URLRequest; | 22 class URLRequest; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace data_reduction_proxy { | 25 namespace data_reduction_proxy { |
| 26 | 26 |
| 27 typedef base::Callback<void(content::WebContents* web_contents, | 27 using OnLoFiResponseReceivedCallback = |
| 28 bool is_preview)> OnLoFiResponseReceivedCallback; | 28 base::Callback<void(content::WebContents* web_contents)>; |
| 29 | 29 |
| 30 // Passes notifications to the UI thread that a Lo-Fi response has been | 30 // Passes notifications to the UI thread that a Lo-Fi response has been |
| 31 // received. These notifications may be used to show Lo-Fi UI. This object lives | 31 // received. These notifications may be used to show Lo-Fi UI. This object lives |
| 32 // on the IO thread and OnLoFiReponseReceived should be called from there. | 32 // on the IO thread and OnLoFiReponseReceived should be called from there. |
| 33 class ContentLoFiUIService : public LoFiUIService { | 33 class ContentLoFiUIService : public LoFiUIService { |
| 34 public: | 34 public: |
| 35 ContentLoFiUIService( | 35 ContentLoFiUIService( |
| 36 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, | 36 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, |
| 37 const OnLoFiResponseReceivedCallback& on_lofi_response_received_callback); | 37 const OnLoFiResponseReceivedCallback& on_lofi_response_received_callback); |
| 38 ~ContentLoFiUIService() override; | 38 ~ContentLoFiUIService() override; |
| 39 | 39 |
| 40 // LoFiUIService implementation: | 40 // LoFiUIService implementation: |
| 41 void OnLoFiReponseReceived(const net::URLRequest& request, | 41 void OnLoFiReponseReceived(const net::URLRequest& request) override; |
| 42 bool is_preview) override; | |
| 43 | 42 |
| 44 private: | 43 private: |
| 45 // Using the |render_process_id| and |render_frame_id|, gets the associated | 44 // Using the |render_process_id| and |render_frame_id|, gets the associated |
| 46 // WebContents if it exists and runs the | 45 // WebContents if it exists and runs the |
| 47 // |notify_lofi_response_received_callback_|. |is_preview| indicates whether | 46 // |notify_lofi_response_received_callback_|. |is_preview| indicates whether |
| 48 // the response was a Lo-Fi preview response. | 47 // the response was a Lo-Fi preview response. |
| 49 void OnLoFiResponseReceivedOnUIThread(int render_process_id, | 48 void OnLoFiResponseReceivedOnUIThread(int render_process_id, |
| 50 int render_frame_id, | 49 int render_frame_id); |
| 51 bool is_preview); | |
| 52 | 50 |
| 53 // A task runner to post calls to OnLoFiReponseReceivedOnUI on the UI | 51 // A task runner to post calls to OnLoFiReponseReceivedOnUI on the UI |
| 54 // thread. | 52 // thread. |
| 55 const scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | 53 const scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
| 56 const OnLoFiResponseReceivedCallback on_lofi_response_received_callback_; | 54 const OnLoFiResponseReceivedCallback on_lofi_response_received_callback_; |
| 57 | 55 |
| 58 DISALLOW_COPY_AND_ASSIGN(ContentLoFiUIService); | 56 DISALLOW_COPY_AND_ASSIGN(ContentLoFiUIService); |
| 59 }; | 57 }; |
| 60 | 58 |
| 61 } // namespace data_reduction_proxy | 59 } // namespace data_reduction_proxy |
| 62 | 60 |
| 63 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CONTENT_BROWSER_CONTENT_LOFI_UI_SERVI
CE_H_ | 61 #endif // COMPONENTS_DATA_REDUCTION_PROXY_CONTENT_BROWSER_CONTENT_LOFI_UI_SERVI
CE_H_ |
| OLD | NEW |