Bug 1526591 - Remove devtools.inspector.shapesHighlighter.enabled pref. r=rcaliman
[gecko.git] / dom / quota / QuotaCommon.h
blobca46df4e808b50542456aa0941948e708b49c9f7
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__
10 #include "nsCOMPtr.h"
11 #include "nsDebug.h"
12 #include "nsPrintfCString.h"
13 #include "nsString.h"
14 #include "nsTArray.h"
16 #define BEGIN_QUOTA_NAMESPACE \
17 namespace mozilla { \
18 namespace dom { \
19 namespace quota {
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(...) \
32 do { \
33 nsPrintfCString str(__VA_ARGS__); \
34 mozilla::dom::quota::ReportInternalError(__FILE__, __LINE__, str.get()); \
35 NS_WARNING(str.get()); \
36 } while (0)
38 // Telemetry probes to collect number of failure during the initialization.
39 #ifdef NIGHTLY_BUILD
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) \
46 do { \
47 if (_initializing) { \
48 REPORT_TELEMETRY_INIT_ERR(_key, _label) \
49 } \
50 } while (0)
52 # define RECORD_IN_NIGHTLY(_recorder, _status) \
53 do { \
54 if (NS_SUCCEEDED(_recorder)) { \
55 _recorder = _status; \
56 } \
57 } while (0)
59 # define CONTINUE_IN_NIGHTLY_RETURN_IN_OTHERS(_dummy) continue
60 #else
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
71 #endif
73 class nsIEventTarget;
75 BEGIN_QUOTA_NAMESPACE
77 // Telemetry keys to indicate types of errors.
78 #ifdef NIGHTLY_BUILD
79 extern const nsLiteralCString kInternalError;
80 extern const nsLiteralCString kExternalError;
81 #else
82 // No need for these when we're not collecting telemetry.
83 # define kInternalError
84 # define kExternalError
85 #endif
87 class BackgroundThreadObject {
88 protected:
89 nsCOMPtr<nsIEventTarget> mOwningThread;
91 public:
92 void AssertIsOnOwningThread() const
93 #ifdef DEBUG
95 #else
98 #endif
100 nsIEventTarget* OwningThread() const;
102 protected:
103 BackgroundThreadObject();
105 explicit BackgroundThreadObject(nsIEventTarget* aOwningThread);
108 void AssertIsOnIOThread();
110 void AssertCurrentThreadOwnsQuotaMutex();
112 bool IsOnIOThread();
114 void ReportInternalError(const char* aFile, uint32_t aLine, const char* aStr);
116 END_QUOTA_NAMESPACE
118 #endif // mozilla_dom_quota_quotacommon_h__