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

Issue 201083003: Oilpan: Prepare to move DatabaseThread and SQLTransactionCoordinator to Oilpan heap. (Closed)

Created:
6 years, 9 months ago by tkent
Modified:
6 years, 9 months ago
CC:
blink-reviews
Visibility:
Public.

Description

Oilpan: Prepare to move DatabaseThread and SQLTransactionCoordinator to Oilpan heap. BUG=347902 Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=169594

Patch Set 1 #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+23 lines, -9 lines) Patch
M Source/modules/webdatabase/DatabaseContext.h View 1 chunk +1 line, -1 line 5 comments Download
M Source/modules/webdatabase/DatabaseThread.h View 2 chunks +5 lines, -4 lines 1 comment Download
M Source/modules/webdatabase/DatabaseThread.cpp View 2 chunks +7 lines, -1 line 0 comments Download
M Source/modules/webdatabase/SQLTransactionCoordinator.h View 2 chunks +5 lines, -3 lines 0 comments Download
M Source/modules/webdatabase/SQLTransactionCoordinator.cpp View 1 chunk +5 lines, -0 lines 0 comments Download

Messages

Total messages: 10 (0 generated)
tkent
please review this.
6 years, 9 months ago (2014-03-19 09:39:43 UTC) #1
haraken
LGTM https://codereview.chromium.org/201083003/diff/1/Source/modules/webdatabase/DatabaseThread.h File Source/modules/webdatabase/DatabaseThread.h (right): https://codereview.chromium.org/201083003/diff/1/Source/modules/webdatabase/DatabaseThread.h#newcode91 Source/modules/webdatabase/DatabaseThread.h:91: DatabaseTaskSynchronizer* m_cleanupSync; This raw pointer looks safe.
6 years, 9 months ago (2014-03-19 09:42:45 UTC) #2
Mads Ager (chromium)
https://codereview.chromium.org/201083003/diff/1/Source/modules/webdatabase/DatabaseContext.h File Source/modules/webdatabase/DatabaseContext.h (right): https://codereview.chromium.org/201083003/diff/1/Source/modules/webdatabase/DatabaseContext.h#newcode78 Source/modules/webdatabase/DatabaseContext.h:78: RefPtrWillBePersistent<DatabaseThread> m_databaseThread; This Persistent is in a ThreadSafeRefCounted class. ...
6 years, 9 months ago (2014-03-19 09:45:26 UTC) #3
tkent
https://codereview.chromium.org/201083003/diff/1/Source/modules/webdatabase/DatabaseContext.h File Source/modules/webdatabase/DatabaseContext.h (right): https://codereview.chromium.org/201083003/diff/1/Source/modules/webdatabase/DatabaseContext.h#newcode78 Source/modules/webdatabase/DatabaseContext.h:78: RefPtrWillBePersistent<DatabaseThread> m_databaseThread; On 2014/03/19 09:45:26, Mads Ager (chromium) wrote: ...
6 years, 9 months ago (2014-03-19 23:43:53 UTC) #4
tkent
The CQ bit was checked by tkent@chromium.org
6 years, 9 months ago (2014-03-19 23:43:57 UTC) #5
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/tkent@chromium.org/201083003/1
6 years, 9 months ago (2014-03-19 23:44:14 UTC) #6
commit-bot: I haz the power
Change committed as 169594
6 years, 9 months ago (2014-03-19 23:45:15 UTC) #7
Mads Ager (chromium)
https://codereview.chromium.org/201083003/diff/1/Source/modules/webdatabase/DatabaseContext.h File Source/modules/webdatabase/DatabaseContext.h (right): https://codereview.chromium.org/201083003/diff/1/Source/modules/webdatabase/DatabaseContext.h#newcode78 Source/modules/webdatabase/DatabaseContext.h:78: RefPtrWillBePersistent<DatabaseThread> m_databaseThread; On 2014/03/19 23:43:53, tkent wrote: > On ...
6 years, 9 months ago (2014-03-20 06:24:15 UTC) #8
Mads Ager (chromium)
https://codereview.chromium.org/201083003/diff/1/Source/modules/webdatabase/DatabaseContext.h File Source/modules/webdatabase/DatabaseContext.h (right): https://codereview.chromium.org/201083003/diff/1/Source/modules/webdatabase/DatabaseContext.h#newcode78 Source/modules/webdatabase/DatabaseContext.h:78: RefPtrWillBePersistent<DatabaseThread> m_databaseThread; On 2014/03/20 06:24:16, Mads Ager (chromium) wrote: ...
6 years, 9 months ago (2014-03-20 06:26:03 UTC) #9
tkent
6 years, 9 months ago (2014-03-20 07:50:09 UTC) #10
Message was sent while issue was closed.
https://codereview.chromium.org/201083003/diff/1/Source/modules/webdatabase/D...
File Source/modules/webdatabase/DatabaseContext.h (right):

https://codereview.chromium.org/201083003/diff/1/Source/modules/webdatabase/D...
Source/modules/webdatabase/DatabaseContext.h:78:
RefPtrWillBePersistent<DatabaseThread> m_databaseThread;
On 2014/03/20 06:26:03, Mads Ager (chromium) wrote:
> On 2014/03/20 06:24:16, Mads Ager (chromium) wrote:
> > On 2014/03/19 23:43:53, tkent wrote:
> > > On 2014/03/19 09:45:26, Mads Ager (chromium) wrote:
> > > > This Persistent is in a ThreadSafeRefCounted class. That means that the
> last
> > > > deref can be from a different thread than the one that allocated this
> > object.
> > > > Don't we need a CrossThreadPersistent here so it is safe to destruct it
on
> > the
> > > > thread that does the last deref?
> > > 
> > > Good point.
> > > DatabaseThread doesn't need to be ThreadSafeRefCounted.  Only this RefPtr
> > holds
> > > a reference count of a DatabaseThread.  So, this CL is safe.
> > > A DatabaseThread object is transferred from a context thread to a database
> > > thread by m_thread->postTask(new Task(WTF::bind(function, this)) in
> > > DatabaseThread.cpp. Ideally this task should have CrossThreadPersistent.
> > However
> > > a raw pointer is ok because DatabaseContext::m_databaseThread has a strong
> > > reference until the database thread is dead.
> > > 
> > > We might need to add ParamStrorageTraits<RawPtr<T>> to wtf/Functional.h in
> the
> > > future though it is unnecessary for DatabaseThread.
> > 
> > Thanks for that part of the explanation Kent!
> > 
> > The thing that worries me is not DataBaseThread. Having that in a Persistent
> > seems fine. The thing that worries me is that DatabaseContext is
> > ThreadSafeRefCounted. That means that in principle it could be created on
one
> > thread and destructed on another thread which would lead to multi-threaded
> > access to a Persistent chain which can lead to a corrupted persistent chain.
> It
> > therefore seems like this Persistent should be a CrossThreadPersistent so
that
> > it can safely be created on one thread and destructed on another.
> > 
> > Is it guaranteed that the DatabaseContext is destructed on the same thread
> that
> > created it?
> 
> It probably is. I guess this is the execution context for the database thread
> that is destructed at the very end of database thread execution?
> 

> Is it guaranteed that the DatabaseContext is destructed on the same thread
that
created it?

Yes.
A DatabaseContext object can be referred by objects in a context thread and
objects in a database thread, and the DatabaseContext object is always outlives
the corresponding database thread. So, m_databasethread is always cleared in the
context thread.

Powered by Google App Engine
This is Rietveld 408576698