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

Side by Side Diff: components/policy/core/common/policy_loader_win.h

Issue 1902633006: Convert //components/policy from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments and use namespace alias Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_WIN_H_ 5 #ifndef COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_WIN_H_
6 #define COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_WIN_H_ 6 #define COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_WIN_H_
7 7
8 #include <windows.h> 8 #include <windows.h>
9 #include <userenv.h> 9 #include <userenv.h>
10 10
11 #include <memory>
12
11 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
12 #include "base/macros.h" 14 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/strings/string16.h" 16 #include "base/strings/string16.h"
16 #include "base/synchronization/waitable_event.h" 17 #include "base/synchronization/waitable_event.h"
17 #include "base/win/object_watcher.h" 18 #include "base/win/object_watcher.h"
18 #include "components/policy/core/common/async_policy_loader.h" 19 #include "components/policy/core/common/async_policy_loader.h"
19 #include "components/policy/core/common/policy_types.h" 20 #include "components/policy/core/common/policy_types.h"
20 #include "components/policy/policy_export.h" 21 #include "components/policy/policy_export.h"
21 22
22 namespace base { 23 namespace base {
23 class SequencedTaskRunner; 24 class SequencedTaskRunner;
24 } 25 }
(...skipping 28 matching lines...) Expand all
53 54
54 // Passing |gpo_provider| equal nullptr forces all reads to go through the 55 // Passing |gpo_provider| equal nullptr forces all reads to go through the
55 // registry. This is undesirable for Chrome (see crbug.com/259236), but 56 // registry. This is undesirable for Chrome (see crbug.com/259236), but
56 // needed for some other use cases (i.e. Chromoting - see crbug.com/460734). 57 // needed for some other use cases (i.e. Chromoting - see crbug.com/460734).
57 PolicyLoaderWin(scoped_refptr<base::SequencedTaskRunner> task_runner, 58 PolicyLoaderWin(scoped_refptr<base::SequencedTaskRunner> task_runner,
58 const base::string16& chrome_policy_key, 59 const base::string16& chrome_policy_key,
59 AppliedGPOListProvider* gpo_provider); 60 AppliedGPOListProvider* gpo_provider);
60 ~PolicyLoaderWin() override; 61 ~PolicyLoaderWin() override;
61 62
62 // Creates a policy loader that uses the Win API to access GPO. 63 // Creates a policy loader that uses the Win API to access GPO.
63 static scoped_ptr<PolicyLoaderWin> Create( 64 static std::unique_ptr<PolicyLoaderWin> Create(
64 scoped_refptr<base::SequencedTaskRunner> task_runner, 65 scoped_refptr<base::SequencedTaskRunner> task_runner,
65 const base::string16& chrome_policy_key); 66 const base::string16& chrome_policy_key);
66 67
67 // AsyncPolicyLoader implementation. 68 // AsyncPolicyLoader implementation.
68 void InitOnBackgroundThread() override; 69 void InitOnBackgroundThread() override;
69 scoped_ptr<PolicyBundle> Load() override; 70 std::unique_ptr<PolicyBundle> Load() override;
70 71
71 private: 72 private:
72 // Reads Chrome Policy from a PReg file at the given path and stores the 73 // Reads Chrome Policy from a PReg file at the given path and stores the
73 // result in |policy|. 74 // result in |policy|.
74 bool ReadPRegFile(const base::FilePath& preg_file, 75 bool ReadPRegFile(const base::FilePath& preg_file,
75 RegistryDict* policy, 76 RegistryDict* policy,
76 PolicyLoadStatusSample* status); 77 PolicyLoadStatusSample* status);
77 78
78 // Loads and parses GPO policy in |policy_object_list| for scope |scope|. If 79 // Loads and parses GPO policy in |policy_object_list| for scope |scope|. If
79 // successful, stores the result in |policy| and returns true. Returns false 80 // successful, stores the result in |policy| and returns true. Returns false
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 base::win::ObjectWatcher machine_policy_watcher_; 120 base::win::ObjectWatcher machine_policy_watcher_;
120 bool user_policy_watcher_failed_; 121 bool user_policy_watcher_failed_;
121 bool machine_policy_watcher_failed_; 122 bool machine_policy_watcher_failed_;
122 123
123 DISALLOW_COPY_AND_ASSIGN(PolicyLoaderWin); 124 DISALLOW_COPY_AND_ASSIGN(PolicyLoaderWin);
124 }; 125 };
125 126
126 } // namespace policy 127 } // namespace policy
127 128
128 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_WIN_H_ 129 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_WIN_H_
OLDNEW
« no previous file with comments | « components/policy/core/common/policy_loader_mac_unittest.cc ('k') | components/policy/core/common/policy_loader_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698