18 #ifndef NET_INSTAWEB_HTTP_PUBLIC_SYNC_FETCHER_ADAPTER_CALLBACK_H_
19 #define NET_INSTAWEB_HTTP_PUBLIC_SYNC_FETCHER_ADAPTER_CALLBACK_H_
28 #include "pagespeed/kernel/base/thread_annotations.h"
30 namespace net_instaweb {
58 void Release() LOCKS_EXCLUDED(mutex_);
60 bool IsDone()
const LOCKS_EXCLUDED(mutex_);
64 bool success()
const LOCKS_EXCLUDED(mutex_);
65 bool released()
const LOCKS_EXCLUDED(mutex_);
73 void Unlock() UNLOCK_FUNCTION(mutex_);
81 void TimedWait(int64 timeout_ms) EXCLUSIVE_LOCKS_REQUIRED(mutex_);
84 virtual void HandleDone(
bool success) LOCKS_EXCLUDED(mutex_);
85 virtual bool HandleWrite(
const StringPiece& content,
86 MessageHandler* handler) {
87 return writer_->Write(content, handler);
89 virtual bool HandleFlush(MessageHandler* handler) {
90 return writer_->Flush(handler);
92 virtual void HandleHeadersComplete() {
100 class ProtectedWriter :
public Writer {
103 : callback_(callback), orig_writer_(orig_writer) {}
105 virtual bool Write(
const StringPiece& buf, MessageHandler* handler)
106 LOCKS_EXCLUDED(callback_->mutex_);
107 virtual bool Flush(MessageHandler* handler)
108 LOCKS_EXCLUDED(callback_->mutex_);
112 Writer* orig_writer_ GUARDED_BY(callback_->mutex_);
114 DISALLOW_COPY_AND_ASSIGN(ProtectedWriter);
118 scoped_ptr<ThreadSystem::CondvarCapableMutex> mutex_;
119 scoped_ptr<ThreadSystem::Condvar> cond_;
121 bool done_ GUARDED_BY(mutex_);
122 bool success_ GUARDED_BY(mutex_);
123 bool released_ GUARDED_BY(mutex_);
124 scoped_ptr<Writer> writer_;
void Release() LOCKS_EXCLUDED(mutex_)
virtual const RequestContextPtr & request_context()
Definition: async_fetch.h:151
Class to help run an asynchronous fetch synchronously with a timeout.
Definition: sync_fetcher_adapter_callback.h:35
void Unlock() UNLOCK_FUNCTION(mutex_)
Releases mutex acquired by a successful LockIfNotReleased() call.
void TimedWait(int64 timeout_ms) EXCLUSIVE_LOCKS_REQUIRED(mutex_)
bool LockIfNotReleased() EXCLUSIVE_TRYLOCK_FUNCTION(true
Definition: async_fetch.h:53
bool IsDoneLockHeld() const EXCLUSIVE_LOCKS_REQUIRED(mutex_)
Version of IsDone() that may only be called if you already hold the mutex.
virtual bool Write(const StringPiece &content, MessageHandler *handler)