Commit 56c2e63c authored by Owen Min's avatar Owen Min Committed by Commit Bot

Add VLOG for MachineLevelUserCloudPolicy

Add VLOG for
1) Token status
2) Enrollment process
3) Policy fetch process (not include the one sent after cache loading)
4) Policy cache load request.

The log will be enabled by --vmodule=machine_level_user_cloud_policy_*=1

Bug: 853364
Change-Id: I8fc6a210513bccd55e3b5d4388969ffc713ce27f
Reviewed-on: https://chromium-review.googlesource.com/1103303
Commit-Queue: Owen Min <zmin@chromium.org>
Reviewed-by: default avatarJulian Pastarmov <pastarmovj@chromium.org>
Reviewed-by: default avatarRoger Tawa <rogerta@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568077}
parent 3cb2e28e
...@@ -23,6 +23,14 @@ ...@@ -23,6 +23,14 @@
namespace policy { namespace policy {
namespace {
void OnPolicyFetchCompleted(bool success) {
VLOG(1) << "Policy fetch " << (success ? "succeeded" : "failed");
}
} // namespace
/* MachineLevelUserCloudPolicyRegistrar */ /* MachineLevelUserCloudPolicyRegistrar */
MachineLevelUserCloudPolicyRegistrar::MachineLevelUserCloudPolicyRegistrar( MachineLevelUserCloudPolicyRegistrar::MachineLevelUserCloudPolicyRegistrar(
DeviceManagementService* device_management_service, DeviceManagementService* device_management_service,
...@@ -106,7 +114,8 @@ void MachineLevelUserCloudPolicyFetcher::SetupRegistrationAndFetchPolicy( ...@@ -106,7 +114,8 @@ void MachineLevelUserCloudPolicyFetcher::SetupRegistrationAndFetchPolicy(
policy_manager_->store()->SetupRegistration(dm_token, client_id); policy_manager_->store()->SetupRegistration(dm_token, client_id);
DCHECK(policy_manager_->IsClientRegistered()); DCHECK(policy_manager_->IsClientRegistered());
policy_manager_->core()->service()->RefreshPolicy(base::DoNothing()); policy_manager_->core()->service()->RefreshPolicy(
base::BindRepeating(&OnPolicyFetchCompleted));
} }
void MachineLevelUserCloudPolicyFetcher::OnInitializationCompleted( void MachineLevelUserCloudPolicyFetcher::OnInitializationCompleted(
...@@ -119,6 +128,8 @@ void MachineLevelUserCloudPolicyFetcher::OnInitializationCompleted( ...@@ -119,6 +128,8 @@ void MachineLevelUserCloudPolicyFetcher::OnInitializationCompleted(
// Note that Chrome will not fetch policy again immediately here if DM server // Note that Chrome will not fetch policy again immediately here if DM server
// returns a policy that Chrome is not able to validate. // returns a policy that Chrome is not able to validate.
if (!policy_manager_->IsClientRegistered()) { if (!policy_manager_->IsClientRegistered()) {
VLOG(1) << "OnInitializationCompleted: Fetching policy when there is no "
"valid local cache.";
TryToFetchPolicy(); TryToFetchPolicy();
} }
} }
...@@ -134,6 +145,8 @@ void MachineLevelUserCloudPolicyFetcher::InitializeManager( ...@@ -134,6 +145,8 @@ void MachineLevelUserCloudPolicyFetcher::InitializeManager(
// which means there is no valid policy cache. // which means there is no valid policy cache.
if (policy_manager_->store()->is_initialized() && if (policy_manager_->store()->is_initialized() &&
!policy_manager_->IsClientRegistered()) { !policy_manager_->IsClientRegistered()) {
VLOG(1) << "InitializeManager: Fetching policy when there is no valid "
"local cache.";
TryToFetchPolicy(); TryToFetchPolicy();
} }
} }
......
...@@ -61,6 +61,10 @@ MachineLevelUserCloudPolicyController::CreatePolicyManager() { ...@@ -61,6 +61,10 @@ MachineLevelUserCloudPolicyController::CreatePolicyManager() {
std::string dm_token = BrowserDMTokenStorage::Get()->RetrieveDMToken(); std::string dm_token = BrowserDMTokenStorage::Get()->RetrieveDMToken();
std::string client_id = BrowserDMTokenStorage::Get()->RetrieveClientId(); std::string client_id = BrowserDMTokenStorage::Get()->RetrieveClientId();
VLOG(1) << "DM token = " << (dm_token.empty() ? "none" : "from persistence");
VLOG(1) << "Enrollment token = " << enrollment_token;
VLOG(1) << "Client ID = " << client_id;
if (enrollment_token.empty() && dm_token.empty()) if (enrollment_token.empty() && dm_token.empty())
return nullptr; return nullptr;
...@@ -105,8 +109,6 @@ void MachineLevelUserCloudPolicyController::Init( ...@@ -105,8 +109,6 @@ void MachineLevelUserCloudPolicyController::Init(
std::string client_id; std::string client_id;
std::string dm_token = BrowserDMTokenStorage::Get()->RetrieveDMToken(); std::string dm_token = BrowserDMTokenStorage::Get()->RetrieveDMToken();
DVLOG(1) << "DM token = " << (dm_token.empty() ? "none" : "from persistence");
if (!dm_token.empty()) { if (!dm_token.empty()) {
policy_fetcher_ = std::make_unique<MachineLevelUserCloudPolicyFetcher>( policy_fetcher_ = std::make_unique<MachineLevelUserCloudPolicyFetcher>(
policy_manager, local_state, device_management_service, policy_manager, local_state, device_management_service,
...@@ -119,8 +121,6 @@ void MachineLevelUserCloudPolicyController::Init( ...@@ -119,8 +121,6 @@ void MachineLevelUserCloudPolicyController::Init(
DCHECK(!enrollment_token.empty()); DCHECK(!enrollment_token.empty());
DCHECK(!client_id.empty()); DCHECK(!client_id.empty());
DVLOG(1) << "Enrollment token = " << enrollment_token;
DVLOG(1) << "Client ID = " << client_id;
policy_registrar_ = std::make_unique<MachineLevelUserCloudPolicyRegistrar>( policy_registrar_ = std::make_unique<MachineLevelUserCloudPolicyRegistrar>(
device_management_service, request_context); device_management_service, request_context);
...@@ -187,14 +187,14 @@ void MachineLevelUserCloudPolicyController:: ...@@ -187,14 +187,14 @@ void MachineLevelUserCloudPolicyController::
RegisterForPolicyWithEnrollmentTokenCallback(const std::string& dm_token, RegisterForPolicyWithEnrollmentTokenCallback(const std::string& dm_token,
const std::string& client_id) { const std::string& client_id) {
if (dm_token.empty()) { if (dm_token.empty()) {
DVLOG(1) << "No DM token returned from browser registration"; VLOG(1) << "No DM token returned from browser registration.";
RecordEnrollmentResult( RecordEnrollmentResult(
MachineLevelUserCloudPolicyEnrollmentResult::kFailedToFetch); MachineLevelUserCloudPolicyEnrollmentResult::kFailedToFetch);
NotifyPolicyRegisterFinished(false); NotifyPolicyRegisterFinished(false);
return; return;
} }
DVLOG(1) << "DM token = retrieved from server"; VLOG(1) << "DM token retrieved from server.";
// TODO(alito): Log failures to store the DM token. Should we try again later? // TODO(alito): Log failures to store the DM token. Should we try again later?
BrowserDMTokenStorage::Get()->StoreDMToken( BrowserDMTokenStorage::Get()->StoreDMToken(
...@@ -211,6 +211,7 @@ void MachineLevelUserCloudPolicyController:: ...@@ -211,6 +211,7 @@ void MachineLevelUserCloudPolicyController::
})); }));
// Start fetching policies. // Start fetching policies.
VLOG(1) << "Fetch policy after enrollment.";
policy_fetcher_->SetupRegistrationAndFetchPolicy(dm_token, client_id); policy_fetcher_->SetupRegistrationAndFetchPolicy(dm_token, client_id);
NotifyPolicyRegisterFinished(true); NotifyPolicyRegisterFinished(true);
} }
......
...@@ -51,9 +51,10 @@ void MachineLevelUserCloudPolicyStore::LoadImmediately() { ...@@ -51,9 +51,10 @@ void MachineLevelUserCloudPolicyStore::LoadImmediately() {
// There is no global dm token, stop loading the policy cache. The policy will // There is no global dm token, stop loading the policy cache. The policy will
// be fetched in the end of enrollment process. // be fetched in the end of enrollment process.
if (machine_dm_token_.empty()) { if (machine_dm_token_.empty()) {
DVLOG(1) << "LoadImmediately ignored, no DM token"; VLOG(1) << "LoadImmediately ignored, no DM token present.";
return; return;
} }
VLOG(1) << "Load policy cache Immediately.";
DesktopCloudPolicyStore::LoadImmediately(); DesktopCloudPolicyStore::LoadImmediately();
} }
...@@ -61,9 +62,10 @@ void MachineLevelUserCloudPolicyStore::Load() { ...@@ -61,9 +62,10 @@ void MachineLevelUserCloudPolicyStore::Load() {
// There is no global dm token, stop loading the policy cache. The policy will // There is no global dm token, stop loading the policy cache. The policy will
// be fetched in the end of enrollment process. // be fetched in the end of enrollment process.
if (machine_dm_token_.empty()) { if (machine_dm_token_.empty()) {
DVLOG(1) << "Load ignored, no DM token"; VLOG(1) << "Load ignored, no DM token present.";
return; return;
} }
VLOG(1) << "Load policy cache.";
DesktopCloudPolicyStore::Load(); DesktopCloudPolicyStore::Load();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment