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

Unified Diff: chrome/browser/sync/api/sync_error.h

Issue 7453014: [Sync] Refactor sync datatype error handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Really fix compile Created 9 years, 5 months 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
Index: chrome/browser/sync/api/sync_error.h
diff --git a/chrome/browser/sync/api/sync_error.h b/chrome/browser/sync/api/sync_error.h
new file mode 100644
index 0000000000000000000000000000000000000000..dc2e89fb9b3c8f22bebd47672d0addfe9dd501b2
--- /dev/null
+++ b/chrome/browser/sync/api/sync_error.h
@@ -0,0 +1,56 @@
+// Copyright (c) 2011 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 CHROME_BROWSER_SYNC_API_SYNC_ERROR_H_
+#define CHROME_BROWSER_SYNC_API_SYNC_ERROR_H_
+#pragma once
+
+#include <string>
+
+#include "base/tracked.h"
akalin 2011/07/21 23:03:53 can just forward-declare Location
Nicolas Zea 2011/07/21 23:43:26 Done.
+#include "base/memory/scoped_ptr.h"
+#include "chrome/browser/sync/syncable/model_type.h"
+
+// Sync errors are used for debug purposes and handled internally and/or
+// exposed through Chrome's "about:sync" internal page. They are considered
+// unrecoverable for the datatype creating them, and should only be used as
+// such.
+// This class is copy-friendly and thread-safe.
+class SyncError {
+ public:
+ // Default constructor refers to "no error", and is_set() will return false.
+ SyncError();
+
+ // Create a new Sync error triggered by datatype |type| with debug message
+ // |message| from the specified location.
+ SyncError(const tracked_objects::Location& location,
+ const std::string& message,
+ syncable::ModelType type);
+
+ // Copy-constructor.
+ SyncError(const SyncError& rhs);
+
akalin 2011/07/21 23:03:53 Just realized you need to implement the assignment
Nicolas Zea 2011/07/21 23:43:26 I suppose it doesn't hurt to, but is it really nee
akalin 2011/07/22 00:10:05 Yeah, because there is a (scoped) pointer variable
+ // Reset the error to a new error.
+ // May be called irrespective of whether is_set() is true.
akalin 2011/07/21 23:03:53 is_set -> IsInitialized()
Nicolas Zea 2011/07/21 23:43:26 Done.
+ void Reset(const tracked_objects::Location& location,
+ const std::string& message,
+ syncable::ModelType type);
+
+ // Whether this is a valid error or not.
+ bool IsInitialized() const;
+
+ // These must only be called if is_set() is true.
+ const tracked_objects::Location& location() const;
+ const std::string& message() const;
+ const syncable::ModelType type() const;
+ private:
akalin 2011/07/21 23:03:53 add line before private:
Nicolas Zea 2011/07/21 23:43:26 Done.
+ void print_log_error() const;
+
+ // Scoped_ptr is necessary because Location objects aren't assignable.
+ scoped_ptr<tracked_objects::Location> location_;
+ std::string message_;
+ syncable::ModelType type_;
+};
+
+#endif // CHROME_BROWSER_SYNC_API_SYNC_ERROR_H_

Powered by Google App Engine
This is Rietveld 408576698