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

Unified Diff: chrome/browser/notifier/chrome_notifier_service.h

Issue 11745024: Synced Notification Sync Change Processor (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: SyncedNotifications - first round of CR comment fixes. Created 7 years, 11 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/notifier/chrome_notifier_service.h
diff --git a/chrome/browser/notifier/chrome_notifier_service.h b/chrome/browser/notifier/chrome_notifier_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..5076587e4d316c94f6720010d85659e83cfb4482
--- /dev/null
+++ b/chrome/browser/notifier/chrome_notifier_service.h
@@ -0,0 +1,74 @@
+// Copyright (c) 2012 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_NOTIFIER_CHROME_NOTIFIER_SERVICE_H_
+#define CHROME_BROWSER_NOTIFIER_CHROME_NOTIFIER_SERVICE_H_
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_vector.h"
+#include "base/threading/non_thread_safe.h"
+#include "chrome/browser/notifier/synced_notification.h"
+#include "chrome/browser/profiles/profile_keyed_service.h"
+#include "sync/api/syncable_service.h"
+
+class Profile;
+class NotificationUIManager;
+
+// The ChromeNotifierService holds notifications which
dcheng 2013/01/18 21:56:13 Optional/preference/nit: I'm just eyeballing this,
Pete Williamson 2013/01/24 01:48:11 Done.
+// represent the state of delivered notifications for chrome.
+// These are obtained from the sync service and kept up to date.
+class ChromeNotifierService : public syncer::SyncableService,
+ public ProfileKeyedService,
+ public base::NonThreadSafe {
dcheng 2013/01/18 21:56:13 Why not use ThreadChecker (which uses composition)
dcheng 2013/01/23 18:39:43 I think you missed the comments in this file.
Pete Williamson 2013/01/24 01:48:11 OK, removed the inheritance from base::NonThreadSa
+
+ public:
+ ChromeNotifierService(Profile* profile, NotificationUIManager* manager);
+ virtual ~ChromeNotifierService();
+
+ // Methods from ProfileKeyedService.
+ virtual void Shutdown() OVERRIDE;
+
+ // syncer::SyncableService implementation.
+ virtual syncer::SyncMergeResult MergeDataAndStartSyncing(
+ syncer::ModelType type,
+ const syncer::SyncDataList& initial_sync_data,
+ scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
+ scoped_ptr<syncer::SyncErrorFactory> error_handler) OVERRIDE;
+ virtual void StopSyncing(syncer::ModelType type) OVERRIDE;
+ virtual syncer::SyncDataList GetAllSyncData(
+ syncer::ModelType type) const OVERRIDE;
+ virtual syncer::SyncError ProcessSyncChanges(
+ const tracked_objects::Location& from_here,
+ const syncer::SyncChangeList& change_list) OVERRIDE;
+
+ // Convert from internal representation to SyncData representation.
+ static syncer::SyncData CreateSyncDataFromNotification(
+ sync_pb::SyncedNotification& notification);
dcheng 2013/01/18 21:56:13 Pass by const reference.
Pete Williamson 2013/01/24 01:48:11 Done.
+
+ // Convert from SyncData representation to internal representation.
+ static sync_pb::SyncedNotification* CreateNotificationFromSyncData(
+ const syncer::SyncData& sync_data);
dcheng 2013/01/18 21:56:13 Optional/preference/nit: I'd personally prefer to
+
+ // Add a notification to our list. This takes ownership of the pointer.
+ void Add(scoped_ptr<sync_pb::SyncedNotification> notification);
+
+ void Show(sync_pb::SyncedNotification* notification);
+
+ // Get a pointer to a notification. ChromeNotifierService owns this pointer.
+ // The caller must not free the it.
dcheng 2013/01/18 21:56:13 s/the//
Pete Williamson 2013/01/24 01:48:11 Done.
+ sync_pb::SyncedNotification* FindNotificationById(const std::string& id);
+
+ private:
+ // Backpointer to the owning profile, do not free at shutdown.
dcheng 2013/01/18 21:56:13 Back pointer. I also feel that "do not free" is re
Pete Williamson 2013/01/24 01:48:11 Done.
+ Profile* profile_;
+ NotificationUIManager* notification_manager_;
+
+ // TODO(petewil): consider whether a map would better suit our data.
+ // If there are many entries, lookup time may trump locality of reference.
+ ScopedVector<sync_pb::SyncedNotification> notification_data_;
+
+ DISALLOW_COPY_AND_ASSIGN(ChromeNotifierService);
+};
+
+#endif // CHROME_BROWSER_NOTIFIER_CHROME_NOTIFIER_SERVICE_H_

Powered by Google App Engine
This is Rietveld 408576698