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

Unified Diff: net/disk_cache/blockfile/mapped_file_avoid_mmap_posix.cc

Issue 992733002: Remove //net (except for Android test stuff) and sdch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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 | « net/disk_cache/blockfile/mapped_file.cc ('k') | net/disk_cache/blockfile/mapped_file_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/blockfile/mapped_file_avoid_mmap_posix.cc
diff --git a/net/disk_cache/blockfile/mapped_file_avoid_mmap_posix.cc b/net/disk_cache/blockfile/mapped_file_avoid_mmap_posix.cc
deleted file mode 100644
index 3936358236dd37d787ff9396fd6fc2e218da7b91..0000000000000000000000000000000000000000
--- a/net/disk_cache/blockfile/mapped_file_avoid_mmap_posix.cc
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "net/disk_cache/blockfile/mapped_file.h"
-
-#include <stdlib.h>
-
-#include "base/files/file_path.h"
-#include "base/logging.h"
-
-namespace disk_cache {
-
-void* MappedFile::Init(const base::FilePath& name, size_t size) {
- DCHECK(!init_);
- if (init_ || !File::Init(name))
- return NULL;
-
- if (!size)
- size = GetLength();
-
- buffer_ = malloc(size);
- snapshot_ = malloc(size);
- if (buffer_ && snapshot_ && Read(buffer_, size, 0)) {
- memcpy(snapshot_, buffer_, size);
- } else {
- free(buffer_);
- free(snapshot_);
- buffer_ = snapshot_ = 0;
- }
-
- init_ = true;
- view_size_ = size;
- return buffer_;
-}
-
-void MappedFile::Flush() {
- DCHECK(buffer_);
- DCHECK(snapshot_);
- const char* buffer_ptr = static_cast<const char*>(buffer_);
- char* snapshot_ptr = static_cast<char*>(snapshot_);
- const size_t block_size = 4096;
- for (size_t offset = 0; offset < view_size_; offset += block_size) {
- size_t size = std::min(view_size_ - offset, block_size);
- if (memcmp(snapshot_ptr + offset, buffer_ptr + offset, size)) {
- memcpy(snapshot_ptr + offset, buffer_ptr + offset, size);
- Write(snapshot_ptr + offset, size, offset);
- }
- }
-}
-
-MappedFile::~MappedFile() {
- if (!init_)
- return;
-
- if (buffer_ && snapshot_) {
- Flush();
- }
- free(buffer_);
- free(snapshot_);
-}
-
-} // namespace disk_cache
« no previous file with comments | « net/disk_cache/blockfile/mapped_file.cc ('k') | net/disk_cache/blockfile/mapped_file_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698