• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 //
5 // An implementation of SyncNotifier that wraps InvalidationNotifier
6 // on its own thread.
7 
8 #ifndef CHROME_BROWSER_SYNC_NOTIFIER_NON_BLOCKING_INVALIDATION_NOTIFIER_H_
9 #define CHROME_BROWSER_SYNC_NOTIFIER_NON_BLOCKING_INVALIDATION_NOTIFIER_H_
10 #pragma once
11 
12 #include <string>
13 
14 #include "base/basictypes.h"
15 #include "base/memory/ref_counted.h"
16 #include "chrome/browser/sync/notifier/sync_notifier.h"
17 #include "jingle/notifier/base/notifier_options.h"
18 
19 namespace base {
20 class MessageLoopProxy;
21 }
22 
23 namespace sync_notifier {
24 
25 class NonBlockingInvalidationNotifier : public SyncNotifier {
26  public:
27   NonBlockingInvalidationNotifier(
28       const notifier::NotifierOptions& notifier_options,
29       const std::string& client_info);
30 
31   virtual ~NonBlockingInvalidationNotifier();
32 
33   // SyncNotifier implementation.
34   virtual void AddObserver(SyncNotifierObserver* observer);
35   virtual void RemoveObserver(SyncNotifierObserver* observer);
36   virtual void SetState(const std::string& state);
37   virtual void UpdateCredentials(
38       const std::string& email, const std::string& token);
39   virtual void UpdateEnabledTypes(const syncable::ModelTypeSet& types);
40   virtual void SendNotification();
41 
42  private:
43   void CheckOrSetValidThread();
44   // The real guts of NonBlockingInvalidationNotifier, which allows this class
45   // to not be refcounted.
46   class Core;
47   scoped_refptr<Core> core_;
48   scoped_refptr<base::MessageLoopProxy> construction_message_loop_proxy_;
49   scoped_refptr<base::MessageLoopProxy> method_message_loop_proxy_;
50   scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_;
51   DISALLOW_COPY_AND_ASSIGN(NonBlockingInvalidationNotifier);
52 };
53 
54 }  // namespace sync_notifier
55 
56 #endif  // CHROME_BROWSER_SYNC_NOTIFIER_NON_BLOCKING_INVALIDATION_NOTIFIER_H_
57