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

Side by Side Diff: webkit/tools/test_shell/simple_appcache_system.h

Issue 12163003: Add FilePath to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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
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 WEBKIT_TOOLS_TEST_SHELL_SIMPLE_APPCACHE_SYSTEM_H_ 5 #ifndef WEBKIT_TOOLS_TEST_SHELL_SIMPLE_APPCACHE_SYSTEM_H_
6 #define WEBKIT_TOOLS_TEST_SHELL_SIMPLE_APPCACHE_SYSTEM_H_ 6 #define WEBKIT_TOOLS_TEST_SHELL_SIMPLE_APPCACHE_SYSTEM_H_
7 7
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
(...skipping 20 matching lines...) Expand all
31 // are handled. This class conspires with SimpleResourceLoaderBridge to 31 // are handled. This class conspires with SimpleResourceLoaderBridge to
32 // retrieve resources from the appcache. 32 // retrieve resources from the appcache.
33 class SimpleAppCacheSystem { 33 class SimpleAppCacheSystem {
34 public: 34 public:
35 // Should be instanced somewhere in main(). If not instanced, the public 35 // Should be instanced somewhere in main(). If not instanced, the public
36 // static methods are all safe no-ops. 36 // static methods are all safe no-ops.
37 SimpleAppCacheSystem(); 37 SimpleAppCacheSystem();
38 virtual ~SimpleAppCacheSystem(); 38 virtual ~SimpleAppCacheSystem();
39 39
40 // One-time main UI thread initialization. 40 // One-time main UI thread initialization.
41 static void InitializeOnUIThread(const FilePath& cache_directory) { 41 static void InitializeOnUIThread(const base::FilePath& cache_directory) {
42 if (instance_) 42 if (instance_)
43 instance_->InitOnUIThread(cache_directory); 43 instance_->InitOnUIThread(cache_directory);
44 } 44 }
45 45
46 // Called by SimpleResourceLoaderBridge's IOThread class. 46 // Called by SimpleResourceLoaderBridge's IOThread class.
47 // Per IO thread initialization. Only one IO thread can exist 47 // Per IO thread initialization. Only one IO thread can exist
48 // at a time, but after IO thread termination a new one can be 48 // at a time, but after IO thread termination a new one can be
49 // started on which this method should be called. The instance 49 // started on which this method should be called. The instance
50 // is assumed to outlive the IO thread. 50 // is assumed to outlive the IO thread.
51 static void InitializeOnIOThread(net::URLRequestContext* request_context) { 51 static void InitializeOnIOThread(net::URLRequestContext* request_context) {
(...skipping 26 matching lines...) Expand all
78 GURL* manifest_url) { 78 GURL* manifest_url) {
79 if (instance_) 79 if (instance_)
80 instance_->GetExtraResponseBits(request, cache_id, manifest_url); 80 instance_->GetExtraResponseBits(request, cache_id, manifest_url);
81 } 81 }
82 82
83 private: 83 private:
84 friend class SimpleBackendProxy; 84 friend class SimpleBackendProxy;
85 friend class SimpleFrontendProxy; 85 friend class SimpleFrontendProxy;
86 86
87 // Instance methods called by our static public methods 87 // Instance methods called by our static public methods
88 void InitOnUIThread(const FilePath& cache_directory); 88 void InitOnUIThread(const base::FilePath& cache_directory);
89 void InitOnIOThread(net::URLRequestContext* request_context); 89 void InitOnIOThread(net::URLRequestContext* request_context);
90 void CleanupIOThread(); 90 void CleanupIOThread();
91 WebKit::WebApplicationCacheHost* CreateCacheHostForWebKit( 91 WebKit::WebApplicationCacheHost* CreateCacheHostForWebKit(
92 WebKit::WebApplicationCacheHostClient* client); 92 WebKit::WebApplicationCacheHostClient* client);
93 void SetExtraRequestBits(net::URLRequest* request, 93 void SetExtraRequestBits(net::URLRequest* request,
94 int host_id, 94 int host_id,
95 ResourceType::Type resource_type); 95 ResourceType::Type resource_type);
96 void GetExtraResponseBits(net::URLRequest* request, 96 void GetExtraResponseBits(net::URLRequest* request,
97 int64* cache_id, 97 int64* cache_id,
98 GURL* manifest_url); 98 GURL* manifest_url);
99 99
100 // Helpers 100 // Helpers
101 MessageLoop* io_message_loop() { return io_message_loop_; } 101 MessageLoop* io_message_loop() { return io_message_loop_; }
102 MessageLoop* ui_message_loop() { return ui_message_loop_; } 102 MessageLoop* ui_message_loop() { return ui_message_loop_; }
103 bool is_io_thread() { return MessageLoop::current() == io_message_loop_; } 103 bool is_io_thread() { return MessageLoop::current() == io_message_loop_; }
104 bool is_ui_thread() { return MessageLoop::current() == ui_message_loop_; } 104 bool is_ui_thread() { return MessageLoop::current() == ui_message_loop_; }
105 bool is_initialized() { 105 bool is_initialized() {
106 return io_message_loop_ && is_initailized_on_ui_thread(); 106 return io_message_loop_ && is_initailized_on_ui_thread();
107 } 107 }
108 bool is_initailized_on_ui_thread() { 108 bool is_initailized_on_ui_thread() {
109 return ui_message_loop_ ? true : false; 109 return ui_message_loop_ ? true : false;
110 } 110 }
111 111
112 FilePath cache_directory_; 112 base::FilePath cache_directory_;
113 MessageLoop* io_message_loop_; 113 MessageLoop* io_message_loop_;
114 MessageLoop* ui_message_loop_; 114 MessageLoop* ui_message_loop_;
115 scoped_refptr<SimpleBackendProxy> backend_proxy_; 115 scoped_refptr<SimpleBackendProxy> backend_proxy_;
116 scoped_refptr<SimpleFrontendProxy> frontend_proxy_; 116 scoped_refptr<SimpleFrontendProxy> frontend_proxy_;
117 appcache::AppCacheFrontendImpl frontend_impl_; 117 appcache::AppCacheFrontendImpl frontend_impl_;
118 118
119 // Created and used only on the IO thread, these do 119 // Created and used only on the IO thread, these do
120 // not survive IO thread termination. If a new IO thread 120 // not survive IO thread termination. If a new IO thread
121 // is started new instances will be created. 121 // is started new instances will be created.
122 appcache::AppCacheBackendImpl* backend_impl_; 122 appcache::AppCacheBackendImpl* backend_impl_;
123 appcache::AppCacheService* service_; 123 appcache::AppCacheService* service_;
124 124
125 // We start a thread for use as the DB thread. 125 // We start a thread for use as the DB thread.
126 base::Thread db_thread_; 126 base::Thread db_thread_;
127 127
128 // A low-tech singleton. 128 // A low-tech singleton.
129 static SimpleAppCacheSystem* instance_; 129 static SimpleAppCacheSystem* instance_;
130 }; 130 };
131 131
132 #endif // WEBKIT_TOOLS_TEST_SHELL_SIMPLE_APPCACHE_SYSTEM_H_ 132 #endif // WEBKIT_TOOLS_TEST_SHELL_SIMPLE_APPCACHE_SYSTEM_H_
OLDNEW
« no previous file with comments | « webkit/tools/test_shell/run_all_tests.cc ('k') | webkit/tools/test_shell/simple_appcache_system.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698