Chromium Code Reviews| 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..d04d9093a94ba0f864b2e421841cd62cb8b45470 |
| --- /dev/null |
| +++ b/chrome/browser/notifier/chrome_notifier_service.h |
| @@ -0,0 +1,83 @@ |
| +// 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 <string> |
| + |
| +#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; |
|
dcheng
2013/01/28 23:35:09
Minor nit: Most people sort these alphabetically.
Pete Williamson
2013/01/29 00:11:43
Done.
|
| + |
| +namespace notifier { |
| + |
| +// The ChromeNotifierService holds notifications which 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: |
| + 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( |
| + const SyncedNotification& notification); |
| + |
| + // Convert from SyncData representation to internal representation. |
| + static scoped_ptr<SyncedNotification> CreateNotificationFromSyncData( |
| + const syncer::SyncData& sync_data); |
| + |
| + // Get a pointer to a notification. ChromeNotifierService owns this pointer. |
| + // The caller must not free it. |
| + notifier::SyncedNotification* FindNotificationById(const std::string& id); |
| + |
| + // functions for test |
| + void AddForTest(scoped_ptr<notifier::SyncedNotification> notification) { |
| + Add(notification.Pass()); |
| + } |
| + |
| + private: |
| + // Add a notification to our list. This takes ownership of the pointer. |
| + void Add(scoped_ptr<notifier::SyncedNotification> notification); |
| + |
| + void Show(notifier::SyncedNotification* notification); |
| + |
| + // Back pointer to the owning profile. |
| + Profile* profile_; |
| + NotificationUIManager* notification_manager_; |
|
dcheng
2013/01/28 23:35:09
Nit: make these T* const so they don't get reset a
Pete Williamson
2013/01/29 00:11:43
Not done, we use this to call the non-const Notifi
dcheng
2013/01/29 00:28:34
T* const is not the same thing as const T*. In par
Pete Williamson
2013/01/29 00:37:49
Oops, I misread your comment thinking you wanted m
|
| + |
| + // TODO(petewil): consider whether a map would better suit our data. |
| + // If there are many entries, lookup time may trump locality of reference. |
| + ScopedVector<notifier::SyncedNotification> notification_data_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ChromeNotifierService); |
| +}; |
| + |
| +} // namespace notifier |
| + |
| +#endif // CHROME_BROWSER_NOTIFIER_CHROME_NOTIFIER_SERVICE_H_ |