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

Unified 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: Changed Client Hint names to match spec Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
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..679010b625f73639c742d574c9cceb5237ca01ee
--- /dev/null
+++ b/chrome/browser/net/client_hints.h
@@ -0,0 +1,46 @@
+// 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"
+
+
+// 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
+
Ryan Sleevi 2013/02/08 22:12:53 nit: delete blank line
bengr 2013/02/26 01:57:20 Done.
+class ClientHints : public base::RefCountedThreadSafe<ClientHints> {
Ryan Sleevi 2013/02/08 22:12:53 Why is this RefCounted? If it's for the UI<->IO th
bengr 2013/02/26 01:57:20 Done.
+ public:
+ ClientHints();
+
+ // Retrieves screen information for use on the IO thread.
+ bool RetrieveScreenInfo();
+
+ // Returns client hints pertaining to screen information. The format is:
+ // "sh=xx, sw=yy, dpr=zz", where xx, yy, and zz are the screen height,
+ // screen width, and device pixel ratio, respectively. These values are the
+ // same as the values returned by the javascript commands:
+ // screen.height, screen.width, and window.devicePixelRatio.
+ std::string GetScreenInfoHints();
+
+ private:
+ friend class ClientHintsTest;
+ friend class base::RefCountedThreadSafe<ClientHints>;
+
+ ~ClientHints();
+ void FetchScreenInfoOnUIThread();
+ void UpdateScreenInfo(int screen_width, int screen_height,
+ float device_pixel_ratio);
+
+ std::string screen_hints_;
+
+ DISALLOW_COPY_AND_ASSIGN(ClientHints);
+};
+
+#endif // CHROME_BROWSER_NET_CLIENT_HINTS_H_

Powered by Google App Engine
This is Rietveld 408576698