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

Side by Side Diff: net/disk_cache/backend_impl.h

Issue 6005015: Revert 70618 - First pass at adding http/backend cache events to the NetLog. ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 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
« no previous file with comments | « net/base/net_log_source_type_list.h ('k') | net/disk_cache/backend_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // See net/disk_cache/disk_cache.h for the public interface of the cache. 5 // See net/disk_cache/disk_cache.h for the public interface of the cache.
6 6
7 #ifndef NET_DISK_CACHE_BACKEND_IMPL_H_ 7 #ifndef NET_DISK_CACHE_BACKEND_IMPL_H_
8 #define NET_DISK_CACHE_BACKEND_IMPL_H_ 8 #define NET_DISK_CACHE_BACKEND_IMPL_H_
9 #pragma once 9 #pragma once
10 10
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/hash_tables.h" 12 #include "base/hash_tables.h"
13 #include "base/timer.h" 13 #include "base/timer.h"
14 #include "net/disk_cache/block_files.h" 14 #include "net/disk_cache/block_files.h"
15 #include "net/disk_cache/disk_cache.h" 15 #include "net/disk_cache/disk_cache.h"
16 #include "net/disk_cache/eviction.h" 16 #include "net/disk_cache/eviction.h"
17 #include "net/disk_cache/in_flight_backend_io.h" 17 #include "net/disk_cache/in_flight_backend_io.h"
18 #include "net/disk_cache/rankings.h" 18 #include "net/disk_cache/rankings.h"
19 #include "net/disk_cache/stats.h" 19 #include "net/disk_cache/stats.h"
20 #include "net/disk_cache/trace.h" 20 #include "net/disk_cache/trace.h"
21 21
22 namespace net {
23 class NetLog;
24 } // namespace net
25
26 namespace disk_cache { 22 namespace disk_cache {
27 23
28 enum BackendFlags { 24 enum BackendFlags {
29 kNone = 0, 25 kNone = 0,
30 kMask = 1, // A mask (for the index table) was specified. 26 kMask = 1, // A mask (for the index table) was specified.
31 kMaxSize = 1 << 1, // A maximum size was provided. 27 kMaxSize = 1 << 1, // A maximum size was provided.
32 kUnitTestMode = 1 << 2, // We are modifying the behavior for testing. 28 kUnitTestMode = 1 << 2, // We are modifying the behavior for testing.
33 kUpgradeMode = 1 << 3, // This is the upgrade tool (dump). 29 kUpgradeMode = 1 << 3, // This is the upgrade tool (dump).
34 kNewEviction = 1 << 4, // Use of new eviction was specified. 30 kNewEviction = 1 << 4, // Use of new eviction was specified.
35 kNoRandom = 1 << 5, // Don't add randomness to the behavior. 31 kNoRandom = 1 << 5, // Don't add randomness to the behavior.
36 kNoLoadProtection = 1 << 6, // Don't act conservatively under load. 32 kNoLoadProtection = 1 << 6, // Don't act conservatively under load.
37 kNoBuffering = 1 << 7 // Disable extended IO buffering. 33 kNoBuffering = 1 << 7 // Disable extended IO buffering.
38 }; 34 };
39 35
40 // This class implements the Backend interface. An object of this 36 // This class implements the Backend interface. An object of this
41 // class handles the operations of the cache for a particular profile. 37 // class handles the operations of the cache for a particular profile.
42 class BackendImpl : public Backend { 38 class BackendImpl : public Backend {
43 friend class Eviction; 39 friend class Eviction;
44 public: 40 public:
45 BackendImpl(const FilePath& path, base::MessageLoopProxy* cache_thread, 41 BackendImpl(const FilePath& path, base::MessageLoopProxy* cache_thread);
46 net::NetLog* net_log);
47 // mask can be used to limit the usable size of the hash table, for testing. 42 // mask can be used to limit the usable size of the hash table, for testing.
48 BackendImpl(const FilePath& path, uint32 mask, 43 BackendImpl(const FilePath& path, uint32 mask,
49 base::MessageLoopProxy* cache_thread, net::NetLog* net_log); 44 base::MessageLoopProxy* cache_thread);
50 ~BackendImpl(); 45 ~BackendImpl();
51 46
52 // Returns a new backend with the desired flags. See the declaration of 47 // Returns a new backend with the desired flags. See the declaration of
53 // CreateCacheBackend(). 48 // CreateCacheBackend().
54 static int CreateBackend(const FilePath& full_path, bool force, 49 static int CreateBackend(const FilePath& full_path, bool force,
55 int max_bytes, net::CacheType type, 50 int max_bytes, net::CacheType type,
56 uint32 flags, base::MessageLoopProxy* thread, 51 uint32 flags, base::MessageLoopProxy* thread,
57 net::NetLog* net_log, Backend** backend, 52 Backend** backend, CompletionCallback* callback);
58 CompletionCallback* callback);
59 53
60 // Performs general initialization for this current instance of the cache. 54 // Performs general initialization for this current instance of the cache.
61 int Init(CompletionCallback* callback); 55 int Init(CompletionCallback* callback);
62 56
63 // Backend interface. 57 // Backend interface.
64 virtual int32 GetEntryCount() const; 58 virtual int32 GetEntryCount() const;
65 virtual int OpenEntry(const std::string& key, Entry** entry, 59 virtual int OpenEntry(const std::string& key, Entry** entry,
66 CompletionCallback* callback); 60 CompletionCallback* callback);
67 virtual int CreateEntry(const std::string& key, Entry** entry, 61 virtual int CreateEntry(const std::string& key, Entry** entry,
68 CompletionCallback* callback); 62 CompletionCallback* callback);
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 uint32 user_flags_; // Flags set by the user. 350 uint32 user_flags_; // Flags set by the user.
357 bool init_; // controls the initialization of the system. 351 bool init_; // controls the initialization of the system.
358 bool restarted_; 352 bool restarted_;
359 bool unit_test_; 353 bool unit_test_;
360 bool read_only_; // Prevents updates of the rankings data (used by tools). 354 bool read_only_; // Prevents updates of the rankings data (used by tools).
361 bool disabled_; 355 bool disabled_;
362 bool new_eviction_; // What eviction algorithm should be used. 356 bool new_eviction_; // What eviction algorithm should be used.
363 bool first_timer_; // True if the timer has not been called. 357 bool first_timer_; // True if the timer has not been called.
364 bool throttle_requests_; 358 bool throttle_requests_;
365 359
366 net::NetLog* net_log_;
367
368 Stats stats_; // Usage statistcs. 360 Stats stats_; // Usage statistcs.
369 base::RepeatingTimer<BackendImpl> timer_; // Usage timer. 361 base::RepeatingTimer<BackendImpl> timer_; // Usage timer.
370 base::WaitableEvent done_; // Signals the end of background work. 362 base::WaitableEvent done_; // Signals the end of background work.
371 scoped_refptr<TraceObject> trace_object_; // Inits internal tracing. 363 scoped_refptr<TraceObject> trace_object_; // Inits internal tracing.
372 ScopedRunnableMethodFactory<BackendImpl> factory_; 364 ScopedRunnableMethodFactory<BackendImpl> factory_;
373 base::WeakPtrFactory<BackendImpl> ptr_factory_; 365 base::WeakPtrFactory<BackendImpl> ptr_factory_;
374 366
375 DISALLOW_COPY_AND_ASSIGN(BackendImpl); 367 DISALLOW_COPY_AND_ASSIGN(BackendImpl);
376 }; 368 };
377 369
378 // Returns the prefered max cache size given the available disk space. 370 // Returns the prefered max cache size given the available disk space.
379 int PreferedCacheSize(int64 available); 371 int PreferedCacheSize(int64 available);
380 372
381 } // namespace disk_cache 373 } // namespace disk_cache
382 374
383 #endif // NET_DISK_CACHE_BACKEND_IMPL_H_ 375 #endif // NET_DISK_CACHE_BACKEND_IMPL_H_
OLDNEW
« no previous file with comments | « net/base/net_log_source_type_list.h ('k') | net/disk_cache/backend_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698