OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_TRANSLATE_CONTENT_BROWSER_DATA_FILE_BROWSER_CLD_DATA_PROVIDER
_H_ | 5 #ifndef COMPONENTS_TRANSLATE_CONTENT_BROWSER_DATA_FILE_BROWSER_CLD_DATA_PROVIDER
_H_ |
6 #define COMPONENTS_TRANSLATE_CONTENT_BROWSER_DATA_FILE_BROWSER_CLD_DATA_PROVIDER
_H_ | 6 #define COMPONENTS_TRANSLATE_CONTENT_BROWSER_DATA_FILE_BROWSER_CLD_DATA_PROVIDER
_H_ |
7 | 7 |
8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "components/translate/content/browser/browser_cld_data_provider.h" | 13 #include "components/translate/content/browser/browser_cld_data_provider.h" |
14 | 14 |
15 namespace translate { | 15 namespace translate { |
16 | 16 |
17 class DataFileBrowserCldDataProvider : public BrowserCldDataProvider { | 17 class DataFileBrowserCldDataProvider : public BrowserCldDataProvider { |
18 public: | 18 public: |
19 explicit DataFileBrowserCldDataProvider(content::RenderViewHost*); | 19 explicit DataFileBrowserCldDataProvider(content::WebContents*); |
20 virtual ~DataFileBrowserCldDataProvider(); | 20 virtual ~DataFileBrowserCldDataProvider(); |
21 // BrowserCldDataProvider implementations: | 21 // BrowserCldDataProvider implementations: |
22 virtual bool OnMessageReceived(const IPC::Message&) OVERRIDE; | 22 virtual bool OnMessageReceived(const IPC::Message&) OVERRIDE; |
23 virtual void OnCldDataRequest() OVERRIDE; | 23 virtual void OnCldDataRequest() OVERRIDE; |
24 virtual void SendCldDataResponse() OVERRIDE; | 24 virtual void SendCldDataResponse() OVERRIDE; |
25 | 25 |
26 // Sets the data file that this data provider will use to fulfill requests. | 26 // Sets the data file that this data provider will use to fulfill requests. |
27 // This method does nothing if the specified path is equal to the path that | 27 // This method does nothing if the specified path is equal to the path that |
28 // is already configured. Otherwise, the specified path is cached and | 28 // is already configured. Otherwise, the specified path is cached and |
29 // subsequent requests for data will attempt to load CLD data from the file | 29 // subsequent requests for data will attempt to load CLD data from the file |
30 // at the specified path. | 30 // at the specified path. |
31 // This method is threadsafe. | 31 // This method is threadsafe. |
32 static void SetCldDataFilePath(const base::FilePath& filePath); | 32 static void SetCldDataFilePath(const base::FilePath& filePath); |
33 | 33 |
34 // Returns the path most recently set by SetDataFilePath. The initial value | 34 // Returns the path most recently set by SetDataFilePath. The initial value |
35 // prior to any such call is the empty path. | 35 // prior to any such call is the empty path. |
36 // This method is threadsafe. | 36 // This method is threadsafe. |
37 static base::FilePath GetCldDataFilePath(); | 37 static base::FilePath GetCldDataFilePath(); |
38 | 38 |
39 private: | 39 private: |
40 void SendCldDataResponseInternal(const base::File*, | 40 void SendCldDataResponseInternal(const base::File*, |
41 const uint64, | 41 const uint64, |
42 const uint64); | 42 const uint64); |
43 static void OnCldDataRequestInternal(); | 43 static void OnCldDataRequestInternal(); |
44 | 44 |
45 content::RenderViewHost* render_view_host_; | 45 content::WebContents* web_contents_; |
46 scoped_ptr<base::WeakPtrFactory<DataFileBrowserCldDataProvider> > | 46 scoped_ptr<base::WeakPtrFactory<DataFileBrowserCldDataProvider> > |
47 weak_pointer_factory_; | 47 weak_pointer_factory_; |
48 | 48 |
49 DISALLOW_COPY_AND_ASSIGN(DataFileBrowserCldDataProvider); | 49 DISALLOW_COPY_AND_ASSIGN(DataFileBrowserCldDataProvider); |
50 }; | 50 }; |
51 | 51 |
52 } // namespace translate | 52 } // namespace translate |
53 | 53 |
54 #endif // COMPONENTS_TRANSLATE_CONTENT_BROWSER_DATA_FILE_BROWSER_CLD_DATA_PROVI
DER_H_ | 54 #endif // COMPONENTS_TRANSLATE_CONTENT_BROWSER_DATA_FILE_BROWSER_CLD_DATA_PROVI
DER_H_ |
OLD | NEW |