1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_quota_quotacommon_h__
8 #define mozilla_dom_quota_quotacommon_h__
12 #include "nsPrintfCString.h"
16 #define BEGIN_QUOTA_NAMESPACE \
20 #define END_QUOTA_NAMESPACE \
21 } /* namespace quota */ \
22 } /* namespace dom */ \
23 } /* namespace mozilla */
24 #define USING_QUOTA_NAMESPACE using namespace mozilla::dom::quota;
26 #define DSSTORE_FILE_NAME ".DS_Store"
27 #define DESKTOP_FILE_NAME ".desktop"
28 #define DESKTOP_INI_FILE_NAME "desktop.ini"
29 #define THUMBS_DB_FILE_NAME "Thumbs.db"
31 #define QM_WARNING(...) \
33 nsPrintfCString str(__VA_ARGS__); \
34 mozilla::dom::quota::ReportInternalError(__FILE__, __LINE__, str.get()); \
35 NS_WARNING(str.get()); \
38 // Telemetry probes to collect number of failure during the initialization.
40 # define REPORT_TELEMETRY_INIT_ERR(_key, _label) \
41 mozilla::Telemetry::AccumulateCategoricalKeyed( \
42 mozilla::dom::quota::_key, \
43 mozilla::Telemetry::LABELS_QM_INIT_TELEMETRY_ERROR::_label);
45 # define REPORT_TELEMETRY_ERR_IN_INIT(_initializing, _key, _label) \
47 if (_initializing) { \
48 REPORT_TELEMETRY_INIT_ERR(_key, _label) \
52 # define RECORD_IN_NIGHTLY(_recorder, _status) \
54 if (NS_SUCCEEDED(_recorder)) { \
55 _recorder = _status; \
59 # define CONTINUE_IN_NIGHTLY_RETURN_IN_OTHERS(_dummy) continue
61 # define REPORT_TELEMETRY_INIT_ERR(_key, _label) \
64 # define REPORT_TELEMETRY_ERR_IN_INIT(_initializing, _key, _label) \
67 # define RECORD_IN_NIGHTLY(_dummy, _status) \
70 # define CONTINUE_IN_NIGHTLY_RETURN_IN_OTHERS(_rv) return _rv
77 // Telemetry keys to indicate types of errors.
79 extern const nsLiteralCString kInternalError
;
80 extern const nsLiteralCString kExternalError
;
82 // No need for these when we're not collecting telemetry.
83 # define kInternalError
84 # define kExternalError
87 class BackgroundThreadObject
{
89 nsCOMPtr
<nsIEventTarget
> mOwningThread
;
92 void AssertIsOnOwningThread() const
100 nsIEventTarget
* OwningThread() const;
103 BackgroundThreadObject();
105 explicit BackgroundThreadObject(nsIEventTarget
* aOwningThread
);
108 void AssertIsOnIOThread();
110 void AssertCurrentThreadOwnsQuotaMutex();
114 void ReportInternalError(const char* aFile
, uint32_t aLine
, const char* aStr
);
118 #endif // mozilla_dom_quota_quotacommon_h__