Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: components/data_reduction_proxy/content/browser/content_lofi_ui_service.cc

Issue 1558553002: Lo-Fi snackbar should only be shown for the first q=low response of a page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/data_reduction_proxy/content/browser/content_lofi_ui_servic e.h"
6
7 #include "base/bind.h"
8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h"
10 #include "content/public/browser/render_frame_host.h"
11 #include "content/public/browser/resource_request_info.h"
12 #include "content/public/browser/web_contents.h"
13 #include "net/url_request/url_request.h"
14
15 namespace data_reduction_proxy {
16
17 ContentLoFiUIService::ContentLoFiUIService(
18 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner,
19 const NotifyLoFiResponseReceivedCallback&
20 notify_lofi_response_received_callback)
21 : ui_task_runner_(ui_task_runner),
22 notify_lofi_response_received_callback_(
23 notify_lofi_response_received_callback) {}
24
25 ContentLoFiUIService::~ContentLoFiUIService() {}
26
27 void ContentLoFiUIService::NotifyLoFiReponseReceived(
28 const net::URLRequest& request) const {
29 int render_process_id = -1;
30 int render_frame_id = -1;
31 if (content::ResourceRequestInfo::GetRenderFrameForRequest(
32 &request, &render_process_id, &render_frame_id)) {
33 ui_task_runner_->PostTask(
34 FROM_HERE,
35 base::Bind(&ContentLoFiUIService::NotifyLoFiResponseReceivedOnUI,
36 base::Unretained(this), render_process_id, render_frame_id));
37 }
38 }
39
40 void ContentLoFiUIService::NotifyLoFiResponseReceivedOnUI(
41 int render_process_id,
42 int render_frame_id) const {
43 DCHECK(ui_task_runner_->BelongsToCurrentThread());
44 content::RenderFrameHost* frame =
45 content::RenderFrameHost::FromID(render_process_id, render_frame_id);
46 if (frame) {
47 DCHECK(!notify_lofi_response_received_callback_.is_null());
tbansal1 2016/01/05 03:10:59 Can you add this DCHECK to the constructor also?
megjablon 2016/01/05 20:13:03 Done.
48 content::WebContents* web_contents =
49 content::WebContents::FromRenderFrameHost(frame);
50 notify_lofi_response_received_callback_.Run(web_contents);
51 }
52 }
53
54 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698