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

Unified Diff: content/browser/renderer_host/duplicate_content_resource_handler.h

Issue 10701151: DuplicateContentResourceHandler to monitor resources and track how many times th… (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: changed static instance to LazyInstance Created 8 years, 5 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
« no previous file with comments | « content/browser/DEPS ('k') | content/browser/renderer_host/duplicate_content_resource_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/duplicate_content_resource_handler.h
===================================================================
--- content/browser/renderer_host/duplicate_content_resource_handler.h (revision 0)
+++ content/browser/renderer_host/duplicate_content_resource_handler.h (revision 0)
@@ -0,0 +1,65 @@
+// 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.
+
+// DuplicateContentResourceHandler keeps a hash of resources seen and based on
+// url. It is an experiment meant to simulate cache hits for both a url-based
+// and a content-based cache.
+
+#ifndef CONTENT_BROWSER_RENDERER_HOST_DUPLICATE_CONTENT_RESOURCE_HANDLER_H_
+#define CONTENT_BROWSER_RENDERER_HOST_DUPLICATE_CONTENT_RESOURCE_HANDLER_H_
+
+#include <string>
+
+#include "base/memory/ref_counted.h"
+#include "content/browser/renderer_host/layered_resource_handler.h"
+#include "third_party/smhasher/src/PMurHash.h"
+#include "webkit/glue/resource_type.h"
+
+namespace net {
+class IOBuffer;
+class URLRequest;
+class URLRequestStatus;
+}
+
+namespace content {
+
+class DuplicateContentResourceHandler: public LayeredResourceHandler {
+ public:
+ DuplicateContentResourceHandler(scoped_ptr<ResourceHandler> next_handler,
+ ResourceType::Type resource_type,
+ net::URLRequest* request);
+ virtual ~DuplicateContentResourceHandler();
+
+ private:
+ // ResourceHandler implementation
+ virtual bool OnWillRead(int request_id,
+ net::IOBuffer** buf,
+ int* buf_size,
+ int min_size) OVERRIDE;
+ virtual bool OnReadCompleted(int request_id,
+ int bytes_read,
+ bool* defer) OVERRIDE;
+ virtual bool OnResponseCompleted(int request_id,
+ const net::URLRequestStatus& status,
+ const std::string& security_info) OVERRIDE;
+
+ void RecordContentMetrics();
+
+ ResourceType::Type resource_type_;
+ int bytes_read_;
+ scoped_refptr<net::IOBuffer> read_buffer_;
+ net::URLRequest* request_;
+
+ // These values are temporary values that are used in each digest of the
+ // inputs for the incremental hash (PMurHash).
+ MH_UINT32 pmurhash_ph1_;
+ MH_UINT32 pmurhash_pcarry_;
+
+ DISALLOW_COPY_AND_ASSIGN(DuplicateContentResourceHandler);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_RENDERER_HOST_DUPLICATE_CONTENT_RESOURCE_HANDLER_H_
+
« no previous file with comments | « content/browser/DEPS ('k') | content/browser/renderer_host/duplicate_content_resource_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698