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

Side by Side Diff: chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc

Issue 12321062: base: Move MemoryMappedFile out of file_util.h and into its own header file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chrome_frame again Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/test/test_file_util_mac.cc ('k') | chrome/installer/test/resource_updater.cc » ('j') | 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/spellchecker/spellcheck_hunspell_dictionary.h" 5 #include "chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/memory_mapped_file.h"
8 #include "base/logging.h" 9 #include "base/logging.h"
9 #include "base/message_loop.h" 10 #include "base/message_loop.h"
10 #include "base/path_service.h" 11 #include "base/path_service.h"
11 #include "chrome/browser/spellchecker/spellcheck_service.h" 12 #include "chrome/browser/spellchecker/spellcheck_service.h"
12 #include "chrome/browser/spellchecker/spellcheck_platform_mac.h" 13 #include "chrome/browser/spellchecker/spellcheck_platform_mac.h"
13 #include "chrome/common/chrome_paths.h" 14 #include "chrome/common/chrome_paths.h"
14 #include "chrome/common/spellcheck_common.h" 15 #include "chrome/common/spellcheck_common.h"
15 #include "chrome/common/spellcheck_messages.h" 16 #include "chrome/common/spellcheck_messages.h"
16 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/render_process_host.h" 18 #include "content/public/browser/render_process_host.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 PathService::Get(chrome::DIR_USER_DATA, &user_dir); 86 PathService::Get(chrome::DIR_USER_DATA, &user_dir);
86 base::FilePath fallback = user_dir.Append(file->path.BaseName()); 87 base::FilePath fallback = user_dir.Append(file->path.BaseName());
87 if (!file_util::PathExists(file->path) && file_util::PathExists(fallback)) 88 if (!file_util::PathExists(file->path) && file_util::PathExists(fallback))
88 file->path = fallback; 89 file->path = fallback;
89 #endif 90 #endif
90 91
91 // Read the dictionary file and scan its data to check for corruption. The 92 // Read the dictionary file and scan its data to check for corruption. The
92 // scoping closes the memory-mapped file before it is opened or deleted. 93 // scoping closes the memory-mapped file before it is opened or deleted.
93 bool bdict_is_valid; 94 bool bdict_is_valid;
94 { 95 {
95 file_util::MemoryMappedFile map; 96 base::MemoryMappedFile map;
96 bdict_is_valid = file_util::PathExists(file->path) && 97 bdict_is_valid = file_util::PathExists(file->path) &&
97 map.Initialize(file->path) && 98 map.Initialize(file->path) &&
98 hunspell::BDict::Verify(reinterpret_cast<const char*>(map.data()), 99 hunspell::BDict::Verify(reinterpret_cast<const char*>(map.data()),
99 map.length()); 100 map.length());
100 } 101 }
101 if (bdict_is_valid) { 102 if (bdict_is_valid) {
102 file->descriptor = base::CreatePlatformFile( 103 file->descriptor = base::CreatePlatformFile(
103 file->path, 104 file->path,
104 base::PLATFORM_FILE_READ | base::PLATFORM_FILE_OPEN, 105 base::PLATFORM_FILE_READ | base::PLATFORM_FILE_OPEN,
105 NULL, 106 NULL,
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 void SpellcheckHunspellDictionary::InformListenersOfInitialization() { 342 void SpellcheckHunspellDictionary::InformListenersOfInitialization() {
342 FOR_EACH_OBSERVER(Observer, observers_, OnHunspellDictionaryInitialized()); 343 FOR_EACH_OBSERVER(Observer, observers_, OnHunspellDictionaryInitialized());
343 } 344 }
344 345
345 void SpellcheckHunspellDictionary::InformListenersOfDownloadFailure() { 346 void SpellcheckHunspellDictionary::InformListenersOfDownloadFailure() {
346 download_status_ = DOWNLOAD_FAILED; 347 download_status_ = DOWNLOAD_FAILED;
347 FOR_EACH_OBSERVER(Observer, 348 FOR_EACH_OBSERVER(Observer,
348 observers_, 349 observers_,
349 OnHunspellDictionaryDownloadFailure()); 350 OnHunspellDictionaryDownloadFailure());
350 } 351 }
OLDNEW
« no previous file with comments | « base/test/test_file_util_mac.cc ('k') | chrome/installer/test/resource_updater.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698