| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_LOADER_H_ | 5 #ifndef CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_LOADER_H_ |
| 6 #define CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_LOADER_H_ | 6 #define CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_LOADER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 const DictionaryValue* policy() const { return policy_.get(); } | 40 const DictionaryValue* policy() const { return policy_.get(); } |
| 41 | 41 |
| 42 protected: | 42 protected: |
| 43 friend class UpdatePolicyTask; | 43 friend class UpdatePolicyTask; |
| 44 | 44 |
| 45 // AsynchronousPolicyLoader objects should only be deleted by | 45 // AsynchronousPolicyLoader objects should only be deleted by |
| 46 // RefCountedThreadSafe. | 46 // RefCountedThreadSafe. |
| 47 friend class base::RefCountedThreadSafe<AsynchronousPolicyLoader>; | 47 friend class base::RefCountedThreadSafe<AsynchronousPolicyLoader>; |
| 48 virtual ~AsynchronousPolicyLoader() {} | 48 virtual ~AsynchronousPolicyLoader() {} |
| 49 | 49 |
| 50 // Schedules a call to UpdatePolicy on |origin_loop_|. | 50 // Schedules a call to UpdatePolicy on |origin_loop_|. Takes ownership of |
| 51 // |new_policy|. |
| 51 void PostUpdatePolicyTask(DictionaryValue* new_policy); | 52 void PostUpdatePolicyTask(DictionaryValue* new_policy); |
| 52 | 53 |
| 53 // Replaces the existing policy to value map with a new one, sending | |
| 54 // notification to the provider if there is a policy change. Must be called on | |
| 55 // |origin_loop_| so that it's safe to call back into the provider, which is | |
| 56 // not thread-safe. | |
| 57 void UpdatePolicy(DictionaryValue* new_policy); | |
| 58 | |
| 59 AsynchronousPolicyProvider::Delegate* delegate() { | 54 AsynchronousPolicyProvider::Delegate* delegate() { |
| 60 return delegate_.get(); | 55 return delegate_.get(); |
| 61 } | 56 } |
| 62 | 57 |
| 63 AsynchronousPolicyProvider* provider() { | 58 AsynchronousPolicyProvider* provider() { |
| 64 return provider_; | 59 return provider_; |
| 65 } | 60 } |
| 66 | 61 |
| 67 private: | 62 private: |
| 68 friend class AsynchronousPolicyLoaderTest; | 63 friend class AsynchronousPolicyLoaderTest; |
| 69 | 64 |
| 65 // Replaces the existing policy to value map with a new one, sending |
| 66 // notification to the provider if there is a policy change. Must be called on |
| 67 // |origin_loop_| so that it's safe to call back into the provider, which is |
| 68 // not thread-safe. Takes ownership of |new_policy|. |
| 69 void UpdatePolicy(DictionaryValue* new_policy); |
| 70 |
| 70 // Provides the low-level mechanics for loading policy. | 71 // Provides the low-level mechanics for loading policy. |
| 71 scoped_ptr<AsynchronousPolicyProvider::Delegate> delegate_; | 72 scoped_ptr<AsynchronousPolicyProvider::Delegate> delegate_; |
| 72 | 73 |
| 73 // Current policy. | 74 // Current policy. |
| 74 scoped_ptr<DictionaryValue> policy_; | 75 scoped_ptr<DictionaryValue> policy_; |
| 75 | 76 |
| 76 // The provider this loader is associated with. Access only on the thread that | 77 // The provider this loader is associated with. Access only on the thread that |
| 77 // called the constructor. See |origin_loop_| below. | 78 // called the constructor. See |origin_loop_| below. |
| 78 AsynchronousPolicyProvider* provider_; | 79 AsynchronousPolicyProvider* provider_; |
| 79 | 80 |
| 80 // The message loop on which this object was constructed. Recorded so that | 81 // The message loop on which this object was constructed. Recorded so that |
| 81 // it's possible to call back into the non thread safe provider to fire the | 82 // it's possible to call back into the non thread safe provider to fire the |
| 82 // notification. | 83 // notification. |
| 83 MessageLoop* origin_loop_; | 84 MessageLoop* origin_loop_; |
| 84 | 85 |
| 85 DISALLOW_COPY_AND_ASSIGN(AsynchronousPolicyLoader); | 86 DISALLOW_COPY_AND_ASSIGN(AsynchronousPolicyLoader); |
| 86 }; | 87 }; |
| 87 | 88 |
| 88 } // namespace policy | 89 } // namespace policy |
| 89 | 90 |
| 90 #endif // CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_LOADER_H_ | 91 #endif // CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_LOADER_H_ |
| OLD | NEW |