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

Unified Diff: ui/gfx/icon_util.cc

Issue 1372303002: Skip flushes on icon writes for 10x better jumplist perf (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review fixes Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/icon_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/icon_util.cc
diff --git a/ui/gfx/icon_util.cc b/ui/gfx/icon_util.cc
index 94a77bb5cb7fe23dadfae8dcb25478c5be26679d..f9758d39f67626b02bf8a1f470ff8338452ed793 100644
--- a/ui/gfx/icon_util.cc
+++ b/ui/gfx/icon_util.cc
@@ -8,6 +8,7 @@
#include "base/files/important_file_writer.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
+#include "base/trace_event/trace_event.h"
#include "base/win/resource_util.h"
#include "base/win/scoped_gdi_object.h"
#include "base/win/scoped_handle.h"
@@ -452,7 +453,8 @@ SkBitmap IconUtil::CreateSkBitmapFromHICONHelper(HICON icon,
// static
bool IconUtil::CreateIconFileFromImageFamily(
const gfx::ImageFamily& image_family,
- const base::FilePath& icon_path) {
+ const base::FilePath& icon_path,
+ WriteType write_type) {
// Creating a set of bitmaps corresponding to the icon images we'll end up
// storing in the icon file. Each bitmap is created by resizing the most
// appropriate image from |image_family| to the desired size.
@@ -516,8 +518,19 @@ bool IconUtil::CreateIconFileFromImageFamily(
DCHECK_EQ(offset, buffer_size);
- std::string data(buffer.begin(), buffer.end());
- return base::ImportantFileWriter::WriteFileAtomically(icon_path, data);
+ if (write_type == NORMAL_WRITE) {
+ auto saved_size =
+ base::WriteFile(icon_path, reinterpret_cast<const char*>(&buffer[0]),
+ static_cast<int>(buffer.size()));
+ if (saved_size == static_cast<int>(buffer.size()))
+ return true;
+ bool delete_success = base::DeleteFile(icon_path, false);
+ DCHECK(delete_success);
+ return false;
+ } else {
+ std::string data(buffer.begin(), buffer.end());
+ return base::ImportantFileWriter::WriteFileAtomically(icon_path, data);
+ }
}
bool IconUtil::PixelsHaveAlpha(const uint32* pixels, size_t num_pixels) {
« no previous file with comments | « ui/gfx/icon_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698