00001 /* 00002 * Copyright 2011 Google Inc. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http:///www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00022 00023 #ifndef NET_INSTAWEB_AUTOMATIC_PUBLIC_RESOURCE_FETCH_H_ 00024 #define NET_INSTAWEB_AUTOMATIC_PUBLIC_RESOURCE_FETCH_H_ 00025 00026 #include "net/instaweb/http/public/async_fetch.h" 00027 #include "net/instaweb/util/public/basictypes.h" 00028 #include "net/instaweb/util/public/google_url.h" 00029 #include "net/instaweb/util/public/string.h" 00030 00031 namespace net_instaweb { 00032 00033 class MessageHandler; 00034 class ResourceManager; 00035 class RewriteDriver; 00036 class RewriteOptions; 00037 class Timer; 00038 00043 class ResourceFetch : public SharedAsyncFetch { 00044 public: 00045 static void Start(ResourceManager* resource_manager, 00046 const GoogleUrl& url, 00047 AsyncFetch* async_fetch, 00048 RewriteOptions* custom_options, 00049 const GoogleString& version); 00050 00051 protected: 00053 virtual void HandleHeadersComplete(); 00054 virtual void HandleDone(bool success); 00055 00056 private: 00057 explicit ResourceFetch(const GoogleUrl& url, 00058 AsyncFetch* async_fetch, 00059 MessageHandler* handler, 00060 RewriteDriver* driver, 00061 Timer* timer, 00062 const GoogleString& version); 00063 virtual ~ResourceFetch(); 00064 00065 GoogleUrl resource_url_; 00066 MessageHandler* message_handler_; 00067 RewriteDriver* driver_; 00068 Timer* timer_; 00069 const GoogleString& version_; 00070 00071 int64 start_time_us_; 00072 int redirect_count_; 00073 00074 DISALLOW_COPY_AND_ASSIGN(ResourceFetch); 00075 }; 00076 00077 } 00078 00079 #endif ///< NET_INSTAWEB_AUTOMATIC_PUBLIC_RESOURCE_FETCH_H_