Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mock_resource_callback.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_MOCK_RESOURCE_CALLBACK_H_
20 #define NET_INSTAWEB_REWRITER_PUBLIC_MOCK_RESOURCE_CALLBACK_H_
21 
22 #include "base/logging.h"
26 
27 namespace net_instaweb {
28 class ThreadSystem;
29 
31  public:
32  explicit MockResourceCallback(const ResourcePtr& resource,
33  ThreadSystem* thread_system)
34  : Resource::AsyncCallback(resource),
35  success_(false),
36  done_(false),
37  notify_(thread_system) {
38  CHECK(thread_system);
39 }
40  virtual ~MockResourceCallback();
41 
42  virtual void Done(bool lock_failure, bool resource_ok) {
43  CHECK(!lock_failure);
44  success_ = resource_ok;
45  done_ = true;
46  notify_.Notify();
47  }
48 
49  bool success() const { return success_; }
50  bool done() const { return done_; }
51  void Wait() {
52  notify_.Wait();
53  }
54 
55  private:
56  bool success_;
57  bool done_;
59 
60 
61 };
62 
63 }
64 
65 #endif
Definition: resource.h:217
A way for one thread to wait for another.
Definition: worker_test_base.h:71
Definition: mock_resource_callback.h:30
Definition: thread_system.h:40