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

Side by Side Diff: chrome/browser/spellchecker/spellcheck_host_impl.h

Issue 7919003: Remove refptr usages from SpellCheckHost (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: remove TODO comments Created 9 years, 1 month 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HOST_IMPL_H_ 5 #ifndef CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HOST_IMPL_H_
6 #define CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HOST_IMPL_H_ 6 #define CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HOST_IMPL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/compiler_specific.h"
12 #include "base/file_path.h" 13 #include "base/file_path.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h"
14 #include "chrome/browser/spellchecker/spellcheck_host.h" 16 #include "chrome/browser/spellchecker/spellcheck_host.h"
15 #include "chrome/browser/spellchecker/spellcheck_profile_provider.h" 17 #include "chrome/browser/spellchecker/spellcheck_profile_provider.h"
16 #include "content/public/common/url_fetcher_delegate.h" 18 #include "content/public/common/url_fetcher_delegate.h"
17 #include "content/public/browser/notification_observer.h" 19 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h" 20 #include "content/public/browser/notification_registrar.h"
19 21
20 // This class implements the SpellCheckHost interface to provide the 22 // This class implements the SpellCheckHost interface to provide the
21 // functionalities listed below: 23 // functionalities listed below:
22 // * Adding a word to the custom dictionary; 24 // * Adding a word to the custom dictionary;
23 // * Storing the custom dictionary to the file, and read it back 25 // * Storing the custom dictionary to the file, and read it back
(...skipping 15 matching lines...) Expand all
39 // can be listed using SpellCheckHost::GetAvailableLanguages() static method. 41 // can be listed using SpellCheckHost::GetAvailableLanguages() static method.
40 class SpellCheckHostImpl : public SpellCheckHost, 42 class SpellCheckHostImpl : public SpellCheckHost,
41 public content::URLFetcherDelegate, 43 public content::URLFetcherDelegate,
42 public content::NotificationObserver { 44 public content::NotificationObserver {
43 public: 45 public:
44 SpellCheckHostImpl(SpellCheckProfileProvider* profile, 46 SpellCheckHostImpl(SpellCheckProfileProvider* profile,
45 const std::string& language, 47 const std::string& language,
46 net::URLRequestContextGetter* request_context_getter, 48 net::URLRequestContextGetter* request_context_getter,
47 SpellCheckHostMetrics* metrics); 49 SpellCheckHostMetrics* metrics);
48 50
51 virtual ~SpellCheckHostImpl();
52
49 void Initialize(); 53 void Initialize();
50 54
51 // SpellCheckHost implementation 55 // SpellCheckHost implementation
52 virtual void UnsetProfile(); 56 virtual void UnsetProfile() OVERRIDE;
53 virtual void InitForRenderer(RenderProcessHost* process); 57 virtual void InitForRenderer(RenderProcessHost* process) OVERRIDE;
54 virtual void AddWord(const std::string& word); 58 virtual void AddWord(const std::string& word) OVERRIDE;
55 virtual const base::PlatformFile& GetDictionaryFile() const; 59 virtual const base::PlatformFile& GetDictionaryFile() const OVERRIDE;
56 virtual const std::string& GetLanguage() const; 60 virtual const std::string& GetLanguage() const OVERRIDE;
57 virtual bool IsUsingPlatformChecker() const; 61 virtual bool IsUsingPlatformChecker() const OVERRIDE;
58 62
59 private: 63 private:
60 typedef SpellCheckProfileProvider::CustomWordList CustomWordList; 64 typedef SpellCheckProfileProvider::CustomWordList CustomWordList;
61 65
62 // These two classes can destruct us. 66 // These two classes can destruct us.
63 friend class BrowserThread; 67 friend class BrowserThread;
64 friend class DeleteTask<SpellCheckHostImpl>; 68 friend class DeleteTask<SpellCheckHostImpl>;
65 69
66 virtual ~SpellCheckHostImpl();
67
68 // Figure out the location for the dictionary. This is only non-trivial for 70 // Figure out the location for the dictionary. This is only non-trivial for
69 // Windows: 71 // Windows:
70 // The default place whether the spellcheck dictionary can reside is 72 // The default place whether the spellcheck dictionary can reside is
71 // chrome::DIR_APP_DICTIONARIES. However, for systemwide installations, 73 // chrome::DIR_APP_DICTIONARIES. However, for systemwide installations,
72 // this directory may not have permissions for download. In that case, the 74 // this directory may not have permissions for download. In that case, the
73 // alternate directory for download is chrome::DIR_USER_DATA. 75 // alternate directory for download is chrome::DIR_USER_DATA.
74 void InitializeDictionaryLocation(); 76 void InitializeDictionaryLocation();
77 void InitializeDictionaryLocationComplete();
75 78
76 // Load and parse the custom words dictionary and open the bdic file. 79 void AddWordComplete(const std::string& word);
77 // Executed on the file thread.
78 void InitializeInternal();
79
80 void InitializeOnFileThread();
81 80
82 // Inform |profile_| that initialization has finished. 81 // Inform |profile_| that initialization has finished.
83 // |custom_words| holds the custom word list which was 82 // |custom_words| holds the custom word list which was
84 // loaded at the file thread. 83 // loaded at the file thread.
85 void InformProfileOfInitializationWithCustomWords( 84 void InformProfileOfInitializationWithCustomWords(
86 CustomWordList* custom_words); 85 CustomWordList* custom_words);
87 86
88 // An alternative version of InformProfileOfInitializationWithCustomWords() 87 // An alternative version of InformProfileOfInitializationWithCustomWords()
89 // which implies empty |custom_words|. 88 // which implies empty |custom_words|.
90 void InformProfileOfInitialization(); 89 void InformProfileOfInitialization();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 net::URLRequestContextGetter* request_context_getter_; 151 net::URLRequestContextGetter* request_context_getter_;
153 152
154 // Used for downloading the dictionary file. 153 // Used for downloading the dictionary file.
155 scoped_ptr<content::URLFetcher> fetcher_; 154 scoped_ptr<content::URLFetcher> fetcher_;
156 155
157 content::NotificationRegistrar registrar_; 156 content::NotificationRegistrar registrar_;
158 157
159 // An optional metrics counter given by the constructor. 158 // An optional metrics counter given by the constructor.
160 SpellCheckHostMetrics* metrics_; 159 SpellCheckHostMetrics* metrics_;
161 160
161 base::WeakPtrFactory<SpellCheckHostImpl> weak_ptr_factory_;
162
163 scoped_ptr<CustomWordList> custom_words_;
164
162 DISALLOW_COPY_AND_ASSIGN(SpellCheckHostImpl); 165 DISALLOW_COPY_AND_ASSIGN(SpellCheckHostImpl);
163 }; 166 };
164 167
165 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HOST_IMPL_H_ 168 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698