Page Speed Optimization Libraries  1.11.33.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
notifying_fetch.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http:///www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_NOTIFYING_FETCH_H_
20 #define NET_INSTAWEB_REWRITER_PUBLIC_NOTIFYING_FETCH_H_
21 
23 #include "pagespeed/kernel/base/basictypes.h"
24 #include "pagespeed/kernel/base/string.h"
25 #include "pagespeed/kernel/base/string_util.h"
26 #include "pagespeed/kernel/http/response_headers.h"
27 #include "pagespeed/kernel/thread/worker_test_base.h"
28 #include "pagespeed/opt/http/request_context.h"
29 
30 namespace net_instaweb {
31 
32 class MessageHandler;
33 class RewriteOptions;
34 
37 class NotifyingFetch : public AsyncFetch {
38  public:
39  NotifyingFetch(const RequestContextPtr& request_context,
40  RewriteOptions* options,
41  const GoogleString& url,
42  WorkerTestBase::SyncPoint* sync,
43  ResponseHeaders* response_headers);
44  virtual ~NotifyingFetch();
45 
46  StringPiece content() { return content_; }
47  bool done() { return done_; }
48  bool success() { return success_; }
49 
50  protected:
51  void HandleHeadersComplete() override {}
52  bool HandleWrite(const StringPiece& content, MessageHandler* handler)
53  override;
54  bool HandleFlush(MessageHandler* handler) override;
55  void HandleDone(bool success) override;
56  bool IsCachedResultValid(const ResponseHeaders& headers) override;
57 
58  private:
59  GoogleString content_;
60  bool done_;
61  bool success_;
62  const RewriteOptions* options_;
63  GoogleString url_;
64  WorkerTestBase::SyncPoint* sync_;
65 
66 
67 };
68 
69 }
70 
71 #endif
Definition: notifying_fetch.h:37
virtual const RequestContextPtr & request_context()
Definition: async_fetch.h:151
ResponseHeaders * response_headers()
See doc for request_headers and set_request_headers.
Definition: async_fetch.h:53
Definition: rewrite_options.h:84
bool IsCachedResultValid(const ResponseHeaders &headers) override