Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_storage_mozStorageAsyncStatement_h_
8 #define mozilla_storage_mozStorageAsyncStatement_h_
10 #include "nsAutoPtr.h"
11 #include "nsString.h"
13 #include "nsTArray.h"
15 #include "mozStorageBindingParamsArray.h"
16 #include "mozStorageStatementData.h"
17 #include "mozIStorageAsyncStatement.h"
18 #include "StorageBaseStatementInternal.h"
19 #include "mozilla/Attributes.h"
21 class nsIXPConnectJSObjectHolder;
22 struct sqlite3_stmt;
24 namespace mozilla {
25 namespace storage {
27 class AsyncStatementJSHelper;
28 class Connection;
30 class AsyncStatement MOZ_FINAL : public mozIStorageAsyncStatement
31 , public StorageBaseStatementInternal
32 {
33 public:
34 NS_DECL_THREADSAFE_ISUPPORTS
35 NS_DECL_MOZISTORAGEASYNCSTATEMENT
36 NS_DECL_MOZISTORAGEBASESTATEMENT
37 NS_DECL_MOZISTORAGEBINDINGPARAMS
38 NS_DECL_STORAGEBASESTATEMENTINTERNAL
40 AsyncStatement();
42 /**
43 * Initializes the object on aDBConnection by preparing the SQL statement
44 * given by aSQLStatement.
45 *
46 * @param aDBConnection
47 * The Connection object this statement is associated with.
48 * @param aNativeConnection
49 * The native Sqlite connection this statement is associated with.
50 * @param aSQLStatement
51 * The SQL statement to prepare that this object will represent.
52 */
53 nsresult initialize(Connection *aDBConnection,
54 sqlite3 *aNativeConnection,
55 const nsACString &aSQLStatement);
57 /**
58 * Obtains and transfers ownership of the array of parameters that are bound
59 * to this statment. This can be null.
60 */
61 inline already_AddRefed<BindingParamsArray> bindingParamsArray()
62 {
63 return mParamsArray.forget();
64 }
67 private:
68 ~AsyncStatement();
70 /**
71 * Clean up the references JS helpers hold to us. For cycle-avoidance reasons
72 * they do not hold reference-counted references to us, so it is important
73 * we do this.
74 */
75 void cleanupJSHelpers();
77 /**
78 * @return a pointer to the BindingParams object to use with our Bind*
79 * method.
80 */
81 mozIStorageBindingParams *getParams();
83 /**
84 * The SQL string as passed by the user. We store it because we create the
85 * async statement on-demand on the async thread.
86 */
87 nsCString mSQLString;
89 /**
90 * Holds the array of parameters to bind to this statement when we execute
91 * it asynchronously.
92 */
93 nsRefPtr<BindingParamsArray> mParamsArray;
95 /**
96 * Caches the JS 'params' helper for this statement.
97 */
98 nsCOMPtr<nsIXPConnectJSObjectHolder> mStatementParamsHolder;
100 /**
101 * Have we been explicitly finalized by the user?
102 */
103 bool mFinalized;
105 /**
106 * Required for access to private mStatementParamsHolder field by
107 * AsyncStatementJSHelper::getParams.
108 */
109 friend class AsyncStatementJSHelper;
110 };
112 } // storage
113 } // mozilla
115 #endif // mozilla_storage_mozStorageAsyncStatement_h_