OLD | NEW |
---|---|
(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 class ScreenHints { | |
Ryan Sleevi
2013/01/16 23:19:56
This should be a struct, not a class, given that a
bengr (incorrect)
2013/01/17 01:50:44
Done.
| |
15 public: | |
16 ScreenHints() : view_bounds(gfx::Rect(0,0)), dpr(0.0), hints_str("") {} | |
17 ScreenHints(int width, int height, float d, std::string s) : | |
18 view_bounds(gfx::Rect(width, height)), dpr(d), hints_str(s) {} | |
19 gfx::Rect view_bounds; | |
20 float dpr; | |
Ryan Sleevi
2013/01/16 23:19:56
style: Do not abbreviate dpr like this.
bengr (incorrect)
2013/01/17 01:50:44
Done.
| |
21 std::string hints_str; | |
22 }; | |
23 | |
24 typedef std::map<std::pair<int, int>, ScreenHints> ScreenMap; | |
25 namespace content { | |
26 class RenderWidgetHostViewPort; | |
27 } | |
Ryan Sleevi
2013/01/16 23:19:56
These typedefs should appear before any class defi
bengr (incorrect)
2013/01/17 01:50:44
Done.
| |
28 | |
29 // ClientHints is a repository in Chrome for information used | |
30 // to create the Client-Hints request header. For more information, see: | |
31 // https://github.com/igrigorik/http-client-hints/blob/master/ | |
32 // draft-grigorik-http-client-hints-00.txt | |
33 | |
34 class ClientHints : public base::RefCountedThreadSafe<ClientHints> { | |
35 public: | |
36 static scoped_refptr<ClientHints> create(); | |
37 ~ClientHints(); | |
Ryan Sleevi
2013/01/16 23:19:56
style: create() should be Create() - although it's
bengr (incorrect)
2013/01/17 01:50:44
Done.
| |
38 // Checks to see if screen information is available for the render view with | |
39 // the given process id and render view id. | |
40 bool IsScreenInfoAvailable(int process_id, int render_view_id); | |
41 | |
42 // Returns client hints pertaining to screen information. The format is: | |
43 // "vh=xx, vw=yy, dpr=zz", where xx, yy, and zz are the viewport height, | |
44 // viewport width, and device pixel ratio, respectively. These values are the | |
45 // same as the values returned by the javascript commands: | |
46 // window.innerHeight, window.innerWidth, and window.devicePixelRatio. | |
47 // The function should be called only if IsScreenInfoAvailable() returns true. | |
48 std::string GetScreenInfoHints(int process_id, int render_view_id); | |
49 | |
50 protected: | |
51 ClientHints(); | |
Ryan Sleevi
2013/01/16 23:19:56
Do you expect people to be subclassing this? You h
bengr (incorrect)
2013/01/17 01:50:44
I don't expect people to be subclassing this. Done
| |
52 | |
53 private: | |
54 void FetchScreenInfoOnUIThread(int process_id, int render_view_id); | |
55 void UpdateScreenInfo(int process_id, int render_view_id, | |
56 int width, int height, | |
Ryan Sleevi
2013/01/16 23:19:56
style: viewport_width, viewport_height ?
bengr (incorrect)
2013/01/17 01:50:44
Done.
| |
57 float dpr); | |
Ryan Sleevi
2013/01/16 23:19:56
style: meaningful name
bengr (incorrect)
2013/01/17 01:50:44
Done.
| |
58 | |
59 ScreenMap screen_hints_; | |
60 | |
61 DISALLOW_COPY_AND_ASSIGN(ClientHints); | |
62 }; | |
63 | |
64 #endif // CHROME_BROWSER_NET_CLIENT_HINTS_H_ | |
OLD | NEW |