Chromium Code Reviews| Index: chrome/browser/net/client_hints.h |
| diff --git a/chrome/browser/net/client_hints.h b/chrome/browser/net/client_hints.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b61736fb8ba6b48dc4e6c24b89153e6e1a6fffa6 |
| --- /dev/null |
| +++ b/chrome/browser/net/client_hints.h |
| @@ -0,0 +1,71 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_NET_CLIENT_HINTS_H_ |
| +#define CHROME_BROWSER_NET_CLIENT_HINTS_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/memory/ref_counted.h" |
| +#include "base/values.h" |
| +#include "ui/gfx/rect.h" |
| + |
| +struct ScreenHints; |
| +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.
|
| + |
| +struct ScreenHints { |
| + ScreenHints() : |
| + view_bounds(gfx::Rect(0, 0)), device_pixel_ratio(0.0), hints_str("") {} |
| + ScreenHints(int width, int height, float d, std::string s) : |
| + view_bounds(gfx::Rect(width, height)), device_pixel_ratio(d), |
| + hints_str(s) {} |
| + gfx::Rect view_bounds; |
| + float device_pixel_ratio; |
| + std::string hints_str; |
| +}; |
| + |
| +namespace content { |
| +class RenderWidgetHostViewPort; |
| +} |
|
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.
|
| + |
|
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.
|
| +// ClientHints is a repository in Chrome for information used |
| +// to create the Client-Hints request header. For more information, see: |
| +// https://github.com/igrigorik/http-client-hints/blob/master/ |
| +// draft-grigorik-http-client-hints-00.txt |
| + |
| +class ClientHints : public base::RefCountedThreadSafe<ClientHints> { |
| + public: |
| + |
| + ClientHints(); |
| + |
| + |
| + // Checks to see if screen information is available for the render view with |
| + // the given process id and render view id. |
| + bool RetrieveScreenInfoIfUnavailable(int process_id, int render_view_id); |
| + |
| + // Returns client hints pertaining to screen information. The format is: |
| + // "vh=xx, vw=yy, dpr=zz", where xx, yy, and zz are the viewport height, |
| + // viewport width, and device pixel ratio, respectively. These values are the |
| + // same as the values returned by the javascript commands: |
| + // window.innerHeight, window.innerWidth, and window.devicePixelRatio. |
| + // The function should be called only if IsScreenInfoAvailable() returns true. |
| + std::string GetScreenInfoHints(int process_id, int render_view_id); |
| + |
| + |
| + private: |
| + friend class ClientHintsTest; |
| + friend class base::RefCountedThreadSafe<ClientHints>; |
| + ~ClientHints(); |
|
Ryan Sleevi
2013/01/17 01:57:56
nit: newline between the friend decls
bengr (incorrect)
2013/01/18 02:12:00
Done.
|
| + bool IsScreenInfoAvailable(int process_id, int render_view_id); |
| + void FetchScreenInfoOnUIThread(int process_id, int render_view_id); |
| + void UpdateScreenInfo(int process_id, int render_view_id, |
| + int viewport_width, int viewport_height, |
| + float device_pixel_ratio); |
| + |
| + ScreenMap screen_hints_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ClientHints); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_NET_CLIENT_HINTS_H_ |