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 // DuplicateContentResourceHandler keeps a hash of resources seen and based on |
| 6 // url. It is an experiment meant to simulate cache hits for both a url-based |
| 7 // and a content-based cache. |
| 8 |
| 9 #ifndef CONTENT_BROWSER_RENDERER_HOST_DUPLICATE_CONTENT_RESOURCE_HANDLER_H_ |
| 10 #define CONTENT_BROWSER_RENDERER_HOST_DUPLICATE_CONTENT_RESOURCE_HANDLER_H_ |
| 11 |
| 12 #include <string> |
| 13 |
| 14 #include "base/memory/ref_counted.h" |
| 15 #include "content/browser/renderer_host/layered_resource_handler.h" |
| 16 #include "third_party/smhasher/src/PMurHash.h" |
| 17 #include "webkit/glue/resource_type.h" |
| 18 |
| 19 namespace net { |
| 20 class IOBuffer; |
| 21 class URLRequest; |
| 22 class URLRequestStatus; |
| 23 } |
| 24 |
| 25 namespace content { |
| 26 |
| 27 class DuplicateContentResourceHandler: public LayeredResourceHandler { |
| 28 public: |
| 29 DuplicateContentResourceHandler(scoped_ptr<ResourceHandler> next_handler, |
| 30 ResourceType::Type resource_type, |
| 31 net::URLRequest* request); |
| 32 virtual ~DuplicateContentResourceHandler(); |
| 33 |
| 34 private: |
| 35 // ResourceHandler implementation |
| 36 virtual bool OnWillRead(int request_id, |
| 37 net::IOBuffer** buf, |
| 38 int* buf_size, |
| 39 int min_size) OVERRIDE; |
| 40 virtual bool OnReadCompleted(int request_id, |
| 41 int bytes_read, |
| 42 bool* defer) OVERRIDE; |
| 43 virtual bool OnResponseCompleted(int request_id, |
| 44 const net::URLRequestStatus& status, |
| 45 const std::string& security_info) OVERRIDE; |
| 46 |
| 47 void RecordContentMetrics(); |
| 48 |
| 49 ResourceType::Type resource_type_; |
| 50 int bytes_read_; |
| 51 scoped_refptr<net::IOBuffer> read_buffer_; |
| 52 net::URLRequest* request_; |
| 53 |
| 54 // These values are temporary values that are used in each digest of the |
| 55 // inputs for the incremental hash (PMurHash). |
| 56 MH_UINT32 pmurhash_ph1_; |
| 57 MH_UINT32 pmurhash_pcarry_; |
| 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(DuplicateContentResourceHandler); |
| 60 }; |
| 61 |
| 62 } // namespace content |
| 63 |
| 64 #endif // CONTENT_BROWSER_RENDERER_HOST_DUPLICATE_CONTENT_RESOURCE_HANDLER_H_ |
| 65 |
OLD | NEW |