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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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
darin (slow to review) 2012/07/25 22:02:06 nit: add a space after the period.
frankwang 2012/07/26 21:46:19 Done.
7 // and 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 void RecordContentMetrics(const net::URLRequestStatus& status);
darin (slow to review) 2012/07/25 22:02:06 nit: put a new line above this function since it i
frankwang 2012/07/26 21:46:19 Done.
47
48 ResourceType::Type resource_type_;
49 int bytes_read_;
50 scoped_refptr<net::IOBuffer> read_buffer_;
51 net::URLRequest* request_;
52
53 // These values are temporary values that are used in each digest of the
54 // inputs for the incremental hash (PMurHash).
55 MH_UINT32 pmurhash_ph1_;
56 MH_UINT32 pmurhash_pcarry_;
57
58 DISALLOW_COPY_AND_ASSIGN(DuplicateContentResourceHandler);
59 };
60
61 } // namespace content
62
63 #endif // CONTENT_BROWSER_RENDERER_HOST_DUPLICATE_CONTENT_RESOURCE_HANDLER_H_
64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698