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

Unified Diff: third_party/WebKit/Source/platform/text/ICUError.h

Issue 2527183002: Add ICUError to handle ICU failures (Closed)
Patch Set: eae review, add invalid argument error Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/BUILD.gn ('k') | third_party/WebKit/Source/platform/text/ICUError.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/text/ICUError.h
diff --git a/third_party/WebKit/Source/platform/text/ICUError.h b/third_party/WebKit/Source/platform/text/ICUError.h
new file mode 100644
index 0000000000000000000000000000000000000000..ad6725cfc325856180b5210454eede79f37681a5
--- /dev/null
+++ b/third_party/WebKit/Source/platform/text/ICUError.h
@@ -0,0 +1,41 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ICUError_h
+#define ICUError_h
+
+#include "platform/PlatformExport.h"
+#include "wtf/Allocator.h"
+#include "wtf/Assertions.h"
+#include <unicode/utypes.h>
+
+namespace blink {
+
+// ICUError provides the unified way to handle ICU errors in Blink.
+class PLATFORM_EXPORT ICUError {
+ STACK_ALLOCATED();
+
+ public:
+ ~ICUError() { crashIfCritical(); }
+
+ UErrorCode* operator&() { return &m_error; }
+ operator UErrorCode() const { return m_error; }
+
+ // Crash the renderer in the appropriate way if critical failure occurred.
+ void crashIfCritical();
+
+ private:
+ UErrorCode m_error = U_ZERO_ERROR;
+
+ void handleFailure();
+};
+
+inline void ICUError::crashIfCritical() {
+ if (U_FAILURE(m_error))
+ handleFailure();
+}
+
+} // namespace blink
+
+#endif // ICUError_h
« no previous file with comments | « third_party/WebKit/Source/platform/BUILD.gn ('k') | third_party/WebKit/Source/platform/text/ICUError.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698