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

Side by Side Diff: Source/modules/webdatabase/SQLStatement.cpp

Issue 103473002: Manage WebSQL callbacks with OwnPtr instead of refcounting (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix RefPtr/OwnPtr transition gcc errors Created 7 years 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
1 /* 1 /*
2 * Copyright (C) 2007, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 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 25 matching lines...) Expand all
36 #include "modules/webdatabase/Database.h" 36 #include "modules/webdatabase/Database.h"
37 #include "modules/webdatabase/DatabaseManager.h" 37 #include "modules/webdatabase/DatabaseManager.h"
38 #include "modules/webdatabase/SQLStatementCallback.h" 38 #include "modules/webdatabase/SQLStatementCallback.h"
39 #include "modules/webdatabase/SQLStatementErrorCallback.h" 39 #include "modules/webdatabase/SQLStatementErrorCallback.h"
40 #include "modules/webdatabase/SQLTransaction.h" 40 #include "modules/webdatabase/SQLTransaction.h"
41 #include "wtf/text/CString.h" 41 #include "wtf/text/CString.h"
42 42
43 namespace WebCore { 43 namespace WebCore {
44 44
45 PassOwnPtr<SQLStatement> SQLStatement::create(Database* database, 45 PassOwnPtr<SQLStatement> SQLStatement::create(Database* database,
46 PassRefPtr<SQLStatementCallback> callback, PassRefPtr<SQLStatementErrorCallb ack> errorCallback) 46 PassOwnPtr<SQLStatementCallback> callback, PassOwnPtr<SQLStatementErrorCallb ack> errorCallback)
47 { 47 {
48 return adoptPtr(new SQLStatement(database, callback, errorCallback)); 48 return adoptPtr(new SQLStatement(database, callback, errorCallback));
49 } 49 }
50 50
51 SQLStatement::SQLStatement(Database* database, PassRefPtr<SQLStatementCallback> callback, 51 SQLStatement::SQLStatement(Database* database, PassOwnPtr<SQLStatementCallback> callback,
52 PassRefPtr<SQLStatementErrorCallback> errorCallback) 52 PassOwnPtr<SQLStatementErrorCallback> errorCallback)
53 : m_statementCallbackWrapper(callback, database->executionContext()) 53 : m_statementCallbackWrapper(callback, database->executionContext())
54 , m_statementErrorCallbackWrapper(errorCallback, database->executionContext( )) 54 , m_statementErrorCallbackWrapper(errorCallback, database->executionContext( ))
55 { 55 {
56 } 56 }
57 57
58 void SQLStatement::setBackend(AbstractSQLStatementBackend* backend) 58 void SQLStatement::setBackend(AbstractSQLStatementBackend* backend)
59 { 59 {
60 m_backend = backend; 60 m_backend = backend;
61 } 61 }
62 62
63 bool SQLStatement::hasCallback() 63 bool SQLStatement::hasCallback()
64 { 64 {
65 return m_statementCallbackWrapper.hasCallback(); 65 return m_statementCallbackWrapper.hasCallback();
66 } 66 }
67 67
68 bool SQLStatement::hasErrorCallback() 68 bool SQLStatement::hasErrorCallback()
69 { 69 {
70 return m_statementErrorCallbackWrapper.hasCallback(); 70 return m_statementErrorCallbackWrapper.hasCallback();
71 } 71 }
72 72
73 bool SQLStatement::performCallback(SQLTransaction* transaction) 73 bool SQLStatement::performCallback(SQLTransaction* transaction)
74 { 74 {
75 ASSERT(transaction); 75 ASSERT(transaction);
76 ASSERT(m_backend); 76 ASSERT(m_backend);
77 77
78 bool callbackError = false; 78 bool callbackError = false;
79 79
80 RefPtr<SQLStatementCallback> callback = m_statementCallbackWrapper.unwrap(); 80 OwnPtr<SQLStatementCallback> callback = m_statementCallbackWrapper.unwrap();
81 RefPtr<SQLStatementErrorCallback> errorCallback = m_statementErrorCallbackWr apper.unwrap(); 81 OwnPtr<SQLStatementErrorCallback> errorCallback = m_statementErrorCallbackWr apper.unwrap();
82 RefPtr<SQLError> error = m_backend->sqlError(); 82 RefPtr<SQLError> error = m_backend->sqlError();
83 83
84 // Call the appropriate statement callback and track if it resulted in an er ror, 84 // Call the appropriate statement callback and track if it resulted in an er ror,
85 // because then we need to jump to the transaction error callback. 85 // because then we need to jump to the transaction error callback.
86 if (error) { 86 if (error) {
87 if (errorCallback) 87 if (errorCallback)
88 callbackError = errorCallback->handleEvent(transaction, error.get()) ; 88 callbackError = errorCallback->handleEvent(transaction, error.get()) ;
89 } else if (callback) { 89 } else if (callback) {
90 RefPtr<SQLResultSet> resultSet = m_backend->sqlResultSet(); 90 RefPtr<SQLResultSet> resultSet = m_backend->sqlResultSet();
91 callbackError = !callback->handleEvent(transaction, resultSet.get()); 91 callbackError = !callback->handleEvent(transaction, resultSet.get());
92 } 92 }
93 93
94 return callbackError; 94 return callbackError;
95 } 95 }
96 96
97 } // namespace WebCore 97 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/webdatabase/SQLStatement.h ('k') | Source/modules/webdatabase/SQLStatementCallback.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698