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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/resource_context.h
diff --git a/content/browser/resource_context.h b/content/browser/resource_context.h
new file mode 100644
index 0000000000000000000000000000000000000000..b98ab65bcf1e11ef998be7996bfda088a19c79e5
--- /dev/null
+++ b/content/browser/resource_context.h
@@ -0,0 +1,59 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_RESOURCE_CONTEXT_H_
+#define CONTENT_BROWSER_RESOURCE_CONTEXT_H_
+
+#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
+#include "base/threading/non_thread_safe.h"
+
+namespace webkit_database {
+class DatabaseTracker;
+} // namespace webkit_database
+
+namespace content {
+
+// ResourceContext contains the relevant context information required for
+// resource loading. It lives on the IO thread.
+class ResourceContext : public base::NonThreadSafe {
+ public:
+ ResourceContext();
+ virtual ~ResourceContext();
+
+ webkit_database::DatabaseTracker* database_tracker() const;
+ void set_database_tracker(webkit_database::DatabaseTracker* tracker);
+
+ private:
+ scoped_refptr<webkit_database::DatabaseTracker> database_tracker_;
+
+ DISALLOW_COPY_AND_ASSIGN(ResourceContext);
+};
+
+// 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
+// IO thread, via Get(). Afterwards, it should be cached. Any object that caches
+// the ResourceContext pointer should have a shorter lifetime than the
+// ResourceContext.
+class ResourceContextGetter {
+ public:
+ virtual ~ResourceContextGetter();
+
+ // Returns a ResourceContext. It's only allowed to be called once. Any
+ // subsequent attempts will crash.
+ const ResourceContext& Get();
+
+ protected:
+ ResourceContextGetter();
+
+ private:
+ virtual const ResourceContext& GetImpl() = 0;
+
+ bool called_get_;
+
+ DISALLOW_COPY_AND_ASSIGN(ResourceContextGetter);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_RESOURCE_CONTEXT_H_
« 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