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

Side by Side Diff: content/browser/resource_context.h

Issue 6825038: Create a content::ResourceContext. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Oops, inverted the assertions. Created 9 years, 8 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) 2011 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 #ifndef CONTENT_BROWSER_RESOURCE_CONTEXT_H_
6 #define CONTENT_BROWSER_RESOURCE_CONTEXT_H_
7
8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/threading/non_thread_safe.h"
11
12 namespace webkit_database {
13 class DatabaseTracker;
14 } // namespace webkit_database
15
16 namespace content {
17
18 // ResourceContext contains the relevant context information required for
19 // resource loading. It lives on the IO thread.
20 class ResourceContext : public base::NonThreadSafe {
21 public:
22 ResourceContext();
23 virtual ~ResourceContext();
24
25 webkit_database::DatabaseTracker* database_tracker() const;
26 void set_database_tracker(webkit_database::DatabaseTracker* tracker);
27
28 private:
29 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_;
30
31 DISALLOW_COPY_AND_ASSIGN(ResourceContext);
32 };
33
34 // ResourceContextGetter is used purely for acquiring a ResourceContext on the
jam 2011/04/11 22:00:41 is there any way we can avoid the getter pattern?
willchan no longer on Chromium 2011/04/11 22:13:05 It's a tradeoff. We lose the ability to use NonThr
35 // IO thread, via Get(). Afterwards, it should be cached. Any object that caches
36 // the ResourceContext pointer should have a shorter lifetime than the
37 // ResourceContext.
38 class ResourceContextGetter {
39 public:
40 virtual ~ResourceContextGetter();
41
42 // Returns a ResourceContext. It's only allowed to be called once. Any
43 // subsequent attempts will crash.
44 const ResourceContext& Get();
45
46 protected:
47 ResourceContextGetter();
48
49 private:
50 virtual const ResourceContext& GetImpl() = 0;
51
52 bool called_get_;
53
54 DISALLOW_COPY_AND_ASSIGN(ResourceContextGetter);
55 };
56
57 } // namespace content
58
59 #endif // CONTENT_BROWSER_RESOURCE_CONTEXT_H_
OLDNEW
« no previous file with comments | « content/browser/renderer_host/resource_message_filter.cc ('k') | content/browser/resource_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698