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

Side by Side Diff: chrome/browser/component_updater/pepper_flash_component_installer.cc

Issue 1107963003: [chrome/browser/component_updater] favor DCHECK_CURRENTLY_ON for better logs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased the patch Created 5 years, 7 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <stdint.h> 5 #include <stdint.h>
6 #include <string.h> 6 #include <string.h>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX) 66 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX)
67 // Pepper Flash plugins have the version encoded in the path itself 67 // Pepper Flash plugins have the version encoded in the path itself
68 // so we need to enumerate the directories to find the full path. 68 // so we need to enumerate the directories to find the full path.
69 // On success, |latest_dir| returns something like: 69 // On success, |latest_dir| returns something like:
70 // <profile>\AppData\Local\Google\Chrome\User Data\PepperFlash\10.3.44.555\. 70 // <profile>\AppData\Local\Google\Chrome\User Data\PepperFlash\10.3.44.555\.
71 // |latest_version| returns the corresponding version number. |older_dirs| 71 // |latest_version| returns the corresponding version number. |older_dirs|
72 // returns directories of all older versions. 72 // returns directories of all older versions.
73 bool GetPepperFlashDirectory(base::FilePath* latest_dir, 73 bool GetPepperFlashDirectory(base::FilePath* latest_dir,
74 Version* latest_version, 74 Version* latest_version,
75 std::vector<base::FilePath>* older_dirs) { 75 std::vector<base::FilePath>* older_dirs) {
76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 76 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
77 base::FilePath base_dir = GetPepperFlashBaseDirectory(); 77 base::FilePath base_dir = GetPepperFlashBaseDirectory();
78 bool found = false; 78 bool found = false;
79 base::FileEnumerator file_enumerator( 79 base::FileEnumerator file_enumerator(
80 base_dir, false, base::FileEnumerator::DIRECTORIES); 80 base_dir, false, base::FileEnumerator::DIRECTORIES);
81 for (base::FilePath path = file_enumerator.Next(); !path.value().empty(); 81 for (base::FilePath path = file_enumerator.Next(); !path.value().empty();
82 path = file_enumerator.Next()) { 82 path = file_enumerator.Next()) {
83 Version version(path.BaseName().MaybeAsASCII()); 83 Version version(path.BaseName().MaybeAsASCII());
84 if (!version.IsValid()) 84 if (!version.IsValid())
85 continue; 85 continue;
86 if (found) { 86 if (found) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 bool IsPepperFlash(const content::WebPluginInfo& plugin) { 140 bool IsPepperFlash(const content::WebPluginInfo& plugin) {
141 // We try to recognize Pepper Flash by the following criteria: 141 // We try to recognize Pepper Flash by the following criteria:
142 // * It is a Pepper plugin. 142 // * It is a Pepper plugin.
143 // * It has the special Flash permissions. 143 // * It has the special Flash permissions.
144 return plugin.is_pepper_plugin() && 144 return plugin.is_pepper_plugin() &&
145 (plugin.pepper_permissions & ppapi::PERMISSION_FLASH); 145 (plugin.pepper_permissions & ppapi::PERMISSION_FLASH);
146 } 146 }
147 147
148 void RegisterPepperFlashWithChrome(const base::FilePath& path, 148 void RegisterPepperFlashWithChrome(const base::FilePath& path,
149 const Version& version) { 149 const Version& version) {
150 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 150 DCHECK_CURRENTLY_ON(BrowserThread::UI);
151 content::PepperPluginInfo plugin_info; 151 content::PepperPluginInfo plugin_info;
152 if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info)) 152 if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info))
153 return; 153 return;
154 154
155 std::vector<content::WebPluginInfo> plugins; 155 std::vector<content::WebPluginInfo> plugins;
156 PluginService::GetInstance()->GetInternalPlugins(&plugins); 156 PluginService::GetInstance()->GetInternalPlugins(&plugins);
157 for (std::vector<content::WebPluginInfo>::const_iterator it = 157 for (std::vector<content::WebPluginInfo>::const_iterator it =
158 plugins.begin(); 158 plugins.begin();
159 it != plugins.end(); 159 it != plugins.end();
160 ++it) { 160 ++it) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 return false; 250 return false;
251 } 251 }
252 252
253 253
254 254
255 namespace { 255 namespace {
256 256
257 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX) 257 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX)
258 void FinishPepperFlashUpdateRegistration(ComponentUpdateService* cus, 258 void FinishPepperFlashUpdateRegistration(ComponentUpdateService* cus,
259 const Version& version) { 259 const Version& version) {
260 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 260 DCHECK_CURRENTLY_ON(BrowserThread::UI);
261 update_client::CrxComponent pepflash; 261 update_client::CrxComponent pepflash;
262 pepflash.name = "pepper_flash"; 262 pepflash.name = "pepper_flash";
263 pepflash.installer = new PepperFlashComponentInstaller(version); 263 pepflash.installer = new PepperFlashComponentInstaller(version);
264 pepflash.version = version; 264 pepflash.version = version;
265 pepflash.pk_hash.assign(kSha2Hash, &kSha2Hash[sizeof(kSha2Hash)]); 265 pepflash.pk_hash.assign(kSha2Hash, &kSha2Hash[sizeof(kSha2Hash)]);
266 if (cus->RegisterComponent(pepflash) != ComponentUpdateService::Status::kOk) { 266 if (cus->RegisterComponent(pepflash) != ComponentUpdateService::Status::kOk) {
267 NOTREACHED() << "Pepper Flash component registration failed."; 267 NOTREACHED() << "Pepper Flash component registration failed.";
268 } 268 }
269 } 269 }
270 270
271 void StartPepperFlashUpdateRegistration(ComponentUpdateService* cus) { 271 void StartPepperFlashUpdateRegistration(ComponentUpdateService* cus) {
272 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 272 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
273 base::FilePath path = GetPepperFlashBaseDirectory(); 273 base::FilePath path = GetPepperFlashBaseDirectory();
274 if (!base::PathExists(path)) { 274 if (!base::PathExists(path)) {
275 if (!base::CreateDirectory(path)) { 275 if (!base::CreateDirectory(path)) {
276 NOTREACHED() << "Could not create Pepper Flash directory."; 276 NOTREACHED() << "Could not create Pepper Flash directory.";
277 return; 277 return;
278 } 278 }
279 } 279 }
280 280
281 Version version(kNullVersion); 281 Version version(kNullVersion);
282 std::vector<base::FilePath> older_dirs; 282 std::vector<base::FilePath> older_dirs;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); 315 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
316 if (cmd_line->HasSwitch(switches::kDisableBundledPpapiFlash)) 316 if (cmd_line->HasSwitch(switches::kDisableBundledPpapiFlash))
317 return; 317 return;
318 BrowserThread::PostTask(BrowserThread::FILE, 318 BrowserThread::PostTask(BrowserThread::FILE,
319 FROM_HERE, 319 FROM_HERE,
320 base::Bind(&StartPepperFlashUpdateRegistration, cus)); 320 base::Bind(&StartPepperFlashUpdateRegistration, cus));
321 #endif 321 #endif
322 } 322 }
323 323
324 } // namespace component_updater 324 } // namespace component_updater
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698