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

Side by Side Diff: third_party/WebKit/Source/modules/webdatabase/DatabaseTask.h

Issue 1477023003: Refactor the Heap into ThreadHeap to prepare for per thread heaps Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2013 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 26 matching lines...) Expand all
37 #include "platform/TaskSynchronizer.h" 37 #include "platform/TaskSynchronizer.h"
38 #include "platform/heap/Handle.h" 38 #include "platform/heap/Handle.h"
39 #include "wtf/OwnPtr.h" 39 #include "wtf/OwnPtr.h"
40 #include "wtf/PassOwnPtr.h" 40 #include "wtf/PassOwnPtr.h"
41 #include "wtf/Threading.h" 41 #include "wtf/Threading.h"
42 #include "wtf/Vector.h" 42 #include "wtf/Vector.h"
43 #include "wtf/text/WTFString.h" 43 #include "wtf/text/WTFString.h"
44 44
45 namespace blink { 45 namespace blink {
46 46
47 // DatabaseTask can be created from main thread and database thread.
haraken 2016/01/07 08:06:21 from main thread => by the main thread
47 class DatabaseTask { 48 class DatabaseTask {
48 WTF_MAKE_NONCOPYABLE(DatabaseTask); USING_FAST_MALLOC(DatabaseTask); 49 WTF_MAKE_NONCOPYABLE(DatabaseTask); USING_FAST_MALLOC(DatabaseTask);
49 public: 50 public:
50 virtual ~DatabaseTask(); 51 virtual ~DatabaseTask();
51 52
52 void run(); 53 void run();
53 54
54 Database* database() const { return m_database.get(); } 55 Database* database() const { return m_database.get(); }
55 #if ENABLE(ASSERT) 56 #if ENABLE(ASSERT)
56 bool hasSynchronizer() const { return m_synchronizer; } 57 bool hasSynchronizer() const { return m_synchronizer; }
57 #endif 58 #endif
58 59
59 protected: 60 protected:
60 DatabaseTask(Database*, TaskSynchronizer*); 61 DatabaseTask(Database*, TaskSynchronizer*);
61 62
62 private: 63 private:
63 virtual void doPerformTask() = 0; 64 virtual void doPerformTask() = 0;
64 virtual void taskCancelled() { } 65 virtual void taskCancelled() { }
65 66
66 CrossThreadPersistent<Database> m_database; 67 XThreadPersistent<Database> m_database;
67 TaskSynchronizer* m_synchronizer; 68 TaskSynchronizer* m_synchronizer;
68 69
69 #if !LOG_DISABLED 70 #if !LOG_DISABLED
70 virtual const char* debugTaskName() const = 0; 71 virtual const char* debugTaskName() const = 0;
71 bool m_complete; 72 bool m_complete;
72 #endif 73 #endif
73 }; 74 };
74 75
75 class Database::DatabaseOpenTask final : public DatabaseTask { 76 class Database::DatabaseOpenTask final : public DatabaseTask {
76 public: 77 public:
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 124
124 private: 125 private:
125 explicit DatabaseTransactionTask(SQLTransactionBackend*); 126 explicit DatabaseTransactionTask(SQLTransactionBackend*);
126 127
127 void doPerformTask() override; 128 void doPerformTask() override;
128 void taskCancelled() override; 129 void taskCancelled() override;
129 #if !LOG_DISABLED 130 #if !LOG_DISABLED
130 const char* debugTaskName() const override; 131 const char* debugTaskName() const override;
131 #endif 132 #endif
132 133
133 CrossThreadPersistent<SQLTransactionBackend> m_transaction; 134 XThreadPersistent<SQLTransactionBackend> m_transaction;
134 }; 135 };
135 136
136 class Database::DatabaseTableNamesTask final : public DatabaseTask { 137 class Database::DatabaseTableNamesTask final : public DatabaseTask {
137 public: 138 public:
138 static PassOwnPtr<DatabaseTableNamesTask> create(Database* db, TaskSynchroni zer* synchronizer, Vector<String>& names) 139 static PassOwnPtr<DatabaseTableNamesTask> create(Database* db, TaskSynchroni zer* synchronizer, Vector<String>& names)
139 { 140 {
140 return adoptPtr(new DatabaseTableNamesTask(db, synchronizer, names)); 141 return adoptPtr(new DatabaseTableNamesTask(db, synchronizer, names));
141 } 142 }
142 143
143 private: 144 private:
144 DatabaseTableNamesTask(Database*, TaskSynchronizer*, Vector<String>& names); 145 DatabaseTableNamesTask(Database*, TaskSynchronizer*, Vector<String>& names);
145 146
146 void doPerformTask() override; 147 void doPerformTask() override;
147 #if !LOG_DISABLED 148 #if !LOG_DISABLED
148 const char* debugTaskName() const override; 149 const char* debugTaskName() const override;
149 #endif 150 #endif
150 151
151 Vector<String>& m_tableNames; 152 Vector<String>& m_tableNames;
152 }; 153 };
153 154
154 } // namespace blink 155 } // namespace blink
155 156
156 #endif // DatabaseTask_h 157 #endif // DatabaseTask_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698