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

Side by Side Diff: chrome/browser/net/client_hints.h

Issue 11970002: Added Client-Hints. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Added unit tests Created 7 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 (c) 2012 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 #ifndef CHROME_BROWSER_NET_CLIENT_HINTS_H_
6 #define CHROME_BROWSER_NET_CLIENT_HINTS_H_
7
8 #include <string>
9
10 #include "base/memory/ref_counted.h"
11 #include "base/values.h"
12 #include "ui/gfx/rect.h"
13
14 struct ScreenHints;
15 typedef std::map<std::pair<int, int>, ScreenHints> ScreenMap;
Ryan Sleevi 2013/01/17 01:57:56 nit: Should this be a dependent type of ClientHint
bengr (incorrect) 2013/01/18 02:12:00 Done.
16
17 struct ScreenHints {
18 ScreenHints() :
19 view_bounds(gfx::Rect(0, 0)), device_pixel_ratio(0.0), hints_str("") {}
20 ScreenHints(int width, int height, float d, std::string s) :
21 view_bounds(gfx::Rect(width, height)), device_pixel_ratio(d),
22 hints_str(s) {}
23 gfx::Rect view_bounds;
24 float device_pixel_ratio;
25 std::string hints_str;
26 };
27
28 namespace content {
29 class RenderWidgetHostViewPort;
30 }
Ryan Sleevi 2013/01/17 01:57:56 I meant including this forward decl. Your typedef
bengr (incorrect) 2013/01/18 02:12:00 Done.
31
Ryan Sleevi 2013/01/17 01:57:56 No suitable namespace here? We use chrome_browser_
bengr (incorrect) 2013/01/18 02:12:00 Done.
32 // ClientHints is a repository in Chrome for information used
33 // to create the Client-Hints request header. For more information, see:
34 // https://github.com/igrigorik/http-client-hints/blob/master/
35 // draft-grigorik-http-client-hints-00.txt
36
37 class ClientHints : public base::RefCountedThreadSafe<ClientHints> {
38 public:
39
40 ClientHints();
41
42
43 // Checks to see if screen information is available for the render view with
44 // the given process id and render view id.
45 bool RetrieveScreenInfoIfUnavailable(int process_id, int render_view_id);
46
47 // Returns client hints pertaining to screen information. The format is:
48 // "vh=xx, vw=yy, dpr=zz", where xx, yy, and zz are the viewport height,
49 // viewport width, and device pixel ratio, respectively. These values are the
50 // same as the values returned by the javascript commands:
51 // window.innerHeight, window.innerWidth, and window.devicePixelRatio.
52 // The function should be called only if IsScreenInfoAvailable() returns true.
53 std::string GetScreenInfoHints(int process_id, int render_view_id);
54
55
56 private:
57 friend class ClientHintsTest;
58 friend class base::RefCountedThreadSafe<ClientHints>;
59 ~ClientHints();
Ryan Sleevi 2013/01/17 01:57:56 nit: newline between the friend decls
bengr (incorrect) 2013/01/18 02:12:00 Done.
60 bool IsScreenInfoAvailable(int process_id, int render_view_id);
61 void FetchScreenInfoOnUIThread(int process_id, int render_view_id);
62 void UpdateScreenInfo(int process_id, int render_view_id,
63 int viewport_width, int viewport_height,
64 float device_pixel_ratio);
65
66 ScreenMap screen_hints_;
67
68 DISALLOW_COPY_AND_ASSIGN(ClientHints);
69 };
70
71 #endif // CHROME_BROWSER_NET_CLIENT_HINTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698