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

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

Issue 983007: Http cache: Add support for a dedicated cache thread. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 7 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/disk_cache/backend_impl.cc ('k') | net/http/http_cache.h » ('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-2008 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 // Defines the public interface of the disk cache. For more details see 5 // Defines the public interface of the disk cache. For more details see
6 // http://dev.chromium.org/developers/design-documents/disk-cache 6 // http://dev.chromium.org/developers/design-documents/disk-cache
7 7
8 #ifndef NET_DISK_CACHE_DISK_CACHE_H_ 8 #ifndef NET_DISK_CACHE_DISK_CACHE_H_
9 #define NET_DISK_CACHE_DISK_CACHE_H_ 9 #define NET_DISK_CACHE_DISK_CACHE_H_
10 10
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 #include "base/time.h" 15 #include "base/time.h"
16 #include "net/base/cache_type.h" 16 #include "net/base/cache_type.h"
17 #include "net/base/completion_callback.h" 17 #include "net/base/completion_callback.h"
18 18
19 class FilePath; 19 class FilePath;
20 class MessageLoop;
20 21
21 namespace net { 22 namespace net {
22 class IOBuffer; 23 class IOBuffer;
23 } 24 }
24 25
25 namespace disk_cache { 26 namespace disk_cache {
26 27
27 class Entry; 28 class Entry;
28 class Backend; 29 class Backend;
29 typedef net::CompletionCallback CompletionCallback; 30 typedef net::CompletionCallback CompletionCallback;
(...skipping 19 matching lines...) Expand all
49 // Note: This function is deprecated. 50 // Note: This function is deprecated.
50 Backend* CreateInMemoryCacheBackend(int max_bytes); 51 Backend* CreateInMemoryCacheBackend(int max_bytes);
51 52
52 // Returns an instance of a Backend of the given |type|. |path| points to a 53 // Returns an instance of a Backend of the given |type|. |path| points to a
53 // folder where the cached data will be stored (if appropriate). This cache 54 // folder where the cached data will be stored (if appropriate). This cache
54 // instance must be the only object that will be reading or writing files to 55 // instance must be the only object that will be reading or writing files to
55 // that folder. The returned object should be deleted when not needed anymore. 56 // that folder. The returned object should be deleted when not needed anymore.
56 // If |force| is true, and there is a problem with the cache initialization, the 57 // If |force| is true, and there is a problem with the cache initialization, the
57 // files will be deleted and a new set will be created. |max_bytes| is the 58 // files will be deleted and a new set will be created. |max_bytes| is the
58 // maximum size the cache can grow to. If zero is passed in as |max_bytes|, the 59 // maximum size the cache can grow to. If zero is passed in as |max_bytes|, the
59 // cache will determine the value to use. The returned pointer can be NULL if a 60 // cache will determine the value to use. |thread| can be used to perform IO
60 // fatal error is found. The actual return value of the function is a net error 61 // operations if a dedicated thread is required; a valid value is expected for
61 // code. If this function returns ERR_IO_PENDING, the |callback| will be invoked 62 // any backend that performs operations on a disk. The returned pointer can be
62 // when a backend is available or a fatal error condition is reached. The 63 // NULL if a fatal error is found. The actual return value of the function is a
63 // pointer to receive the |backend| must remain valid until the operation 64 // net error code. If this function returns ERR_IO_PENDING, the |callback| will
64 // completes. 65 // be invoked when a backend is available or a fatal error condition is reached.
66 // The pointer to receive the |backend| must remain valid until the operation
67 // completes (the callback is notified).
65 int CreateCacheBackend(net::CacheType type, const FilePath& path, int max_bytes, 68 int CreateCacheBackend(net::CacheType type, const FilePath& path, int max_bytes,
66 bool force, Backend** backend, 69 bool force, MessageLoop* thread, Backend** backend,
67 CompletionCallback* callback); 70 CompletionCallback* callback);
68 71
69 // The root interface for a disk cache instance. 72 // The root interface for a disk cache instance.
70 class Backend { 73 class Backend {
71 public: 74 public:
72 // If the backend is destroyed when there are operations in progress (any 75 // If the backend is destroyed when there are operations in progress (any
73 // callback that has not been invoked yet), this method cancels said 76 // callback that has not been invoked yet), this method cancels said
74 // operations so the callbacks are not invoked, possibly leaving the work 77 // operations so the callbacks are not invoked, possibly leaving the work
75 // half way (for instance, dooming just a few entries). Note that pending IO 78 // half way (for instance, dooming just a few entries). Note that pending IO
76 // for a given Entry (as opposed to the Backend) will still generate a 79 // for a given Entry (as opposed to the Backend) will still generate a
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 // Note: This method is deprecated. 348 // Note: This method is deprecated.
346 virtual int ReadyForSparseIO(CompletionCallback* completion_callback) = 0; 349 virtual int ReadyForSparseIO(CompletionCallback* completion_callback) = 0;
347 350
348 protected: 351 protected:
349 virtual ~Entry() {} 352 virtual ~Entry() {}
350 }; 353 };
351 354
352 } // namespace disk_cache 355 } // namespace disk_cache
353 356
354 #endif // NET_DISK_CACHE_DISK_CACHE_H_ 357 #endif // NET_DISK_CACHE_DISK_CACHE_H_
OLDNEW
« no previous file with comments | « net/disk_cache/backend_impl.cc ('k') | net/http/http_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698