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

Side by Side Diff: chrome/browser/extensions/extension_sync_data.cc

Issue 947673002: Get more useful LOG(FATAL) messages from ExtensionSyncData to help diagnose crashes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: stringprintf Created 5 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/extensions/extension_sync_data.h" 5 #include "chrome/browser/extensions/extension_sync_data.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/stringprintf.h"
8 #include "chrome/browser/extensions/app_sync_data.h" 9 #include "chrome/browser/extensions/app_sync_data.h"
9 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
10 #include "components/crx_file/id_util.h" 11 #include "components/crx_file/id_util.h"
11 #include "extensions/common/extension.h" 12 #include "extensions/common/extension.h"
12 #include "extensions/common/manifest_url_handlers.h" 13 #include "extensions/common/manifest_url_handlers.h"
13 #include "sync/api/sync_data.h" 14 #include "sync/api/sync_data.h"
14 #include "sync/protocol/extension_specifics.pb.h" 15 #include "sync/protocol/extension_specifics.pb.h"
15 #include "sync/protocol/sync.pb.h" 16 #include "sync/protocol/sync.pb.h"
16 17
17 namespace extensions { 18 namespace extensions {
18 19
20 namespace {
21
22 std::string GetExtensionSpecificsLogMessage(
23 const sync_pb::ExtensionSpecifics& specifics) {
24 return base::StringPrintf("id: %s\nversion: %s\nupdate_url: %s",
25 specifics.id().c_str(),
26 specifics.version().c_str(),
27 specifics.update_url().c_str());
28 }
29
30 } // namespace
31
19 ExtensionSyncData::ExtensionSyncData() 32 ExtensionSyncData::ExtensionSyncData()
20 : uninstalled_(false), 33 : uninstalled_(false),
21 enabled_(false), 34 enabled_(false),
22 incognito_enabled_(false), 35 incognito_enabled_(false),
23 remote_install_(false), 36 remote_install_(false),
24 all_urls_enabled_(BOOLEAN_UNSET), 37 all_urls_enabled_(BOOLEAN_UNSET),
25 installed_by_custodian_(false) { 38 installed_by_custodian_(false) {
26 } 39 }
27 40
28 ExtensionSyncData::ExtensionSyncData(const syncer::SyncData& sync_data) 41 ExtensionSyncData::ExtensionSyncData(const syncer::SyncData& sync_data)
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 specifics->set_remote_install(remote_install_); 102 specifics->set_remote_install(remote_install_);
90 if (all_urls_enabled_ != BOOLEAN_UNSET) 103 if (all_urls_enabled_ != BOOLEAN_UNSET)
91 specifics->set_all_urls_enabled(all_urls_enabled_ == BOOLEAN_TRUE); 104 specifics->set_all_urls_enabled(all_urls_enabled_ == BOOLEAN_TRUE);
92 specifics->set_installed_by_custodian(installed_by_custodian_); 105 specifics->set_installed_by_custodian(installed_by_custodian_);
93 specifics->set_name(name_); 106 specifics->set_name(name_);
94 } 107 }
95 108
96 void ExtensionSyncData::PopulateFromExtensionSpecifics( 109 void ExtensionSyncData::PopulateFromExtensionSpecifics(
97 const sync_pb::ExtensionSpecifics& specifics) { 110 const sync_pb::ExtensionSpecifics& specifics) {
98 if (!crx_file::id_util::IdIsValid(specifics.id())) { 111 if (!crx_file::id_util::IdIsValid(specifics.id())) {
99 LOG(FATAL) << "Attempt to sync bad ExtensionSpecifics."; 112 LOG(FATAL) << "Attempt to sync bad ExtensionSpecifics (bad ID):\n"
113 << GetExtensionSpecificsLogMessage(specifics);
100 } 114 }
101 115
102 Version specifics_version(specifics.version()); 116 Version specifics_version(specifics.version());
103 if (!specifics_version.IsValid()) 117 if (!specifics_version.IsValid()) {
104 LOG(FATAL) << "Attempt to sync bad ExtensionSpecifics."; 118 LOG(FATAL) << "Attempt to sync bad ExtensionSpecifics (bad version):\n"
119 << GetExtensionSpecificsLogMessage(specifics);
120 }
105 121
106 // The update URL must be either empty or valid. 122 // The update URL must be either empty or valid.
107 GURL specifics_update_url(specifics.update_url()); 123 GURL specifics_update_url(specifics.update_url());
108 if (!specifics_update_url.is_empty() && !specifics_update_url.is_valid()) { 124 if (!specifics_update_url.is_empty() && !specifics_update_url.is_valid()) {
109 LOG(FATAL) << "Attempt to sync bad ExtensionSpecifics."; 125 LOG(FATAL) << "Attempt to sync bad ExtensionSpecifics (bad update URL):\n"
126 << GetExtensionSpecificsLogMessage(specifics);
110 } 127 }
111 128
112 id_ = specifics.id(); 129 id_ = specifics.id();
113 update_url_ = specifics_update_url; 130 update_url_ = specifics_update_url;
114 version_ = specifics_version; 131 version_ = specifics_version;
115 enabled_ = specifics.enabled(); 132 enabled_ = specifics.enabled();
116 incognito_enabled_ = specifics.incognito_enabled(); 133 incognito_enabled_ = specifics.incognito_enabled();
117 if (specifics.has_all_urls_enabled()) { 134 if (specifics.has_all_urls_enabled()) {
118 all_urls_enabled_ = 135 all_urls_enabled_ =
119 specifics.all_urls_enabled() ? BOOLEAN_TRUE : BOOLEAN_FALSE; 136 specifics.all_urls_enabled() ? BOOLEAN_TRUE : BOOLEAN_FALSE;
(...skipping 16 matching lines...) Expand all
136 const sync_pb::EntitySpecifics& entity_specifics = sync_data.GetSpecifics(); 153 const sync_pb::EntitySpecifics& entity_specifics = sync_data.GetSpecifics();
137 154
138 if (entity_specifics.has_extension()) { 155 if (entity_specifics.has_extension()) {
139 PopulateFromExtensionSpecifics(entity_specifics.extension()); 156 PopulateFromExtensionSpecifics(entity_specifics.extension());
140 } else { 157 } else {
141 LOG(FATAL) << "Attempt to sync bad EntitySpecifics."; 158 LOG(FATAL) << "Attempt to sync bad EntitySpecifics.";
142 } 159 }
143 } 160 }
144 161
145 } // namespace extensions 162 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698