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

Unified Diff: Source/core/platform/PurgeableBuffer.h

Issue 16379004: Android should be able to discard CachedResources (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 7 years, 6 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 | « Source/core/platform/PurgePriority.h ('k') | Source/core/platform/PurgeableBuffer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/platform/PurgeableBuffer.h
diff --git a/Source/core/platform/PurgeableBuffer.h b/Source/core/platform/PurgeableBuffer.h
index 517c1b213bd3ef04655689de2a11b3dd8bcbba59..3ad0992e229b2623f6abee13794187735b90425e 100644
--- a/Source/core/platform/PurgeableBuffer.h
+++ b/Source/core/platform/PurgeableBuffer.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2008, 2010 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2013 Google Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,50 +27,45 @@
#ifndef PurgeableBuffer_h
#define PurgeableBuffer_h
-#include "core/platform/PurgePriority.h"
-#include <wtf/PassOwnPtr.h>
-#include <wtf/Vector.h>
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+
+namespace WebKit {
+class WebDiscardableMemory;
+}
namespace WebCore {
- class PurgeableBuffer {
- WTF_MAKE_NONCOPYABLE(PurgeableBuffer);
- public:
- static PassOwnPtr<PurgeableBuffer> create(const char* data, size_t);
-
- ~PurgeableBuffer();
+class PurgeableBuffer {
+ WTF_MAKE_NONCOPYABLE(PurgeableBuffer);
+public:
+ static PassOwnPtr<PurgeableBuffer> create(const char* data, size_t);
+ ~PurgeableBuffer();
- // Call makePurgeable(false) and check the return value before accessing the data.
- const char* data() const;
- size_t size() const { return m_size; }
-
- PurgePriority purgePriority() const { return m_purgePriority; }
- void setPurgePriority(PurgePriority priority) { m_purgePriority = priority; }
-
- bool isPurgeable() const { return m_state != NonVolatile; }
- bool wasPurged() const;
+ // Call lock and check the return value before accessing the data.
+ const char* data() const;
+ size_t size() const { return m_size; }
- bool makePurgeable(bool purgeable);
+ bool isPurgeable() const { return m_state != Locked; }
+ bool wasPurged() const;
- private:
- PurgeableBuffer(char* data, size_t);
-
- char* m_data;
- size_t m_size;
- PurgePriority m_purgePriority;
+ bool lock();
+ void unlock();
- enum State { NonVolatile, Volatile, Purged };
- mutable State m_state;
+private:
+ enum State {
+ Locked,
+ Unlocked,
+ Purged
};
-#if !ENABLE(PURGEABLE_MEMORY)
- inline PassOwnPtr<PurgeableBuffer> PurgeableBuffer::create(const char*, size_t) { return nullptr; }
- inline PurgeableBuffer::~PurgeableBuffer() { }
- inline const char* PurgeableBuffer::data() const { return 0; }
- inline bool PurgeableBuffer::wasPurged() const { return false; }
- inline bool PurgeableBuffer::makePurgeable(bool) { return false; }
-#endif
-
+ PurgeableBuffer(PassOwnPtr<WebKit::WebDiscardableMemory>, const char* data, size_t);
+
+ OwnPtr<WebKit::WebDiscardableMemory> m_memory;
+ size_t m_size;
+ State m_state;
+};
+
}
#endif
« no previous file with comments | « Source/core/platform/PurgePriority.h ('k') | Source/core/platform/PurgeableBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698