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

Side by Side Diff: components/nacl/browser/nacl_browser.cc

Issue 1154283003: Change most uses of Pickle to base::Pickle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "components/nacl/browser/nacl_browser.h" 5 #include "components/nacl/browser/nacl_browser.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_proxy.h" 8 #include "base/files/file_proxy.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 77 }
78 #endif 78 #endif
79 79
80 void ReadCache(const base::FilePath& filename, std::string* data) { 80 void ReadCache(const base::FilePath& filename, std::string* data) {
81 if (!base::ReadFileToString(filename, data)) { 81 if (!base::ReadFileToString(filename, data)) {
82 // Zero-size data used as an in-band error code. 82 // Zero-size data used as an in-band error code.
83 data->clear(); 83 data->clear();
84 } 84 }
85 } 85 }
86 86
87 void WriteCache(const base::FilePath& filename, const Pickle* pickle) { 87 void WriteCache(const base::FilePath& filename, const base::Pickle* pickle) {
88 base::WriteFile(filename, static_cast<const char*>(pickle->data()), 88 base::WriteFile(filename, static_cast<const char*>(pickle->data()),
89 pickle->size()); 89 pickle->size());
90 } 90 }
91 91
92 void RemoveCache(const base::FilePath& filename, 92 void RemoveCache(const base::FilePath& filename,
93 const base::Closure& callback) { 93 const base::Closure& callback) {
94 base::DeleteFile(filename, false); 94 base::DeleteFile(filename, false);
95 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, 95 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
96 callback); 96 callback);
97 } 97 }
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 350 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
351 // Did the cache get cleared before the load completed? If so, ignore the 351 // Did the cache get cleared before the load completed? If so, ignore the
352 // incoming data. 352 // incoming data.
353 if (validation_cache_state_ == NaClResourceReady) 353 if (validation_cache_state_ == NaClResourceReady)
354 return; 354 return;
355 355
356 if (data->size() == 0) { 356 if (data->size() == 0) {
357 // No file found. 357 // No file found.
358 validation_cache_.Reset(); 358 validation_cache_.Reset();
359 } else { 359 } else {
360 Pickle pickle(data->data(), data->size()); 360 base::Pickle pickle(data->data(), data->size());
361 validation_cache_.Deserialize(&pickle); 361 validation_cache_.Deserialize(&pickle);
362 } 362 }
363 validation_cache_state_ = NaClResourceReady; 363 validation_cache_state_ = NaClResourceReady;
364 CheckWaiting(); 364 CheckWaiting();
365 } 365 }
366 366
367 void NaClBrowser::RunWithoutValidationCache() { 367 void NaClBrowser::RunWithoutValidationCache() {
368 // Be paranoid. 368 // Be paranoid.
369 validation_cache_.Reset(); 369 validation_cache_.Reset();
370 validation_cache_is_enabled_ = false; 370 validation_cache_is_enabled_ = false;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 } 521 }
522 } 522 }
523 523
524 void NaClBrowser::PersistValidationCache() { 524 void NaClBrowser::PersistValidationCache() {
525 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 525 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
526 // validation_cache_is_modified_ may be false if the cache was cleared while 526 // validation_cache_is_modified_ may be false if the cache was cleared while
527 // this delayed task was pending. 527 // this delayed task was pending.
528 // validation_cache_file_path_ may be empty if something went wrong during 528 // validation_cache_file_path_ may be empty if something went wrong during
529 // initialization. 529 // initialization.
530 if (validation_cache_is_modified_ && !validation_cache_file_path_.empty()) { 530 if (validation_cache_is_modified_ && !validation_cache_file_path_.empty()) {
531 Pickle* pickle = new Pickle(); 531 base::Pickle* pickle = new base::Pickle();
532 validation_cache_.Serialize(pickle); 532 validation_cache_.Serialize(pickle);
533 533
534 // Pass the serialized data to another thread to write to disk. File IO is 534 // Pass the serialized data to another thread to write to disk. File IO is
535 // not allowed on the IO thread (which is the thread this method runs on) 535 // not allowed on the IO thread (which is the thread this method runs on)
536 // because it can degrade the responsiveness of the browser. 536 // because it can degrade the responsiveness of the browser.
537 // The task is sequenced so that multiple writes happen in order. 537 // The task is sequenced so that multiple writes happen in order.
538 content::BrowserThread::PostBlockingPoolSequencedTask( 538 content::BrowserThread::PostBlockingPoolSequencedTask(
539 kValidationCacheSequenceName, 539 kValidationCacheSequenceName,
540 FROM_HERE, 540 FROM_HERE,
541 base::Bind(WriteCache, validation_cache_file_path_, 541 base::Bind(WriteCache, validation_cache_file_path_,
(...skipping 18 matching lines...) Expand all
560 bool NaClBrowser::IsThrottled() { 560 bool NaClBrowser::IsThrottled() {
561 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 561 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
562 if (crash_times_.size() != kMaxCrashesPerInterval) { 562 if (crash_times_.size() != kMaxCrashesPerInterval) {
563 return false; 563 return false;
564 } 564 }
565 base::TimeDelta delta = base::Time::Now() - crash_times_.front(); 565 base::TimeDelta delta = base::Time::Now() - crash_times_.front();
566 return delta.InSeconds() <= kCrashesIntervalInSeconds; 566 return delta.InSeconds() <= kCrashesIntervalInSeconds;
567 } 567 }
568 568
569 } // namespace nacl 569 } // namespace nacl
OLDNEW
« no previous file with comments | « components/bookmarks/browser/bookmark_node_data_views.cc ('k') | components/nacl/browser/nacl_validation_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698