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

Side by Side Diff: Source/core/loader/ThreadableLoaderClientWrapper.h

Issue 1184403003: Offer Resource Timing in workers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: style fix Created 5 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 23 matching lines...) Expand all
34 #include "core/loader/ThreadableLoaderClient.h" 34 #include "core/loader/ThreadableLoaderClient.h"
35 #include "wtf/Noncopyable.h" 35 #include "wtf/Noncopyable.h"
36 #include "wtf/PassRefPtr.h" 36 #include "wtf/PassRefPtr.h"
37 #include "wtf/ThreadSafeRefCounted.h" 37 #include "wtf/ThreadSafeRefCounted.h"
38 #include "wtf/Threading.h" 38 #include "wtf/Threading.h"
39 39
40 namespace blink { 40 namespace blink {
41 41
42 class ThreadableLoaderClientWrapper : public ThreadSafeRefCounted<ThreadableLoad erClientWrapper> { 42 class ThreadableLoaderClientWrapper : public ThreadSafeRefCounted<ThreadableLoad erClientWrapper> {
43 public: 43 public:
44 class ResourceTimingClient {
45 public:
46 virtual void didReceiveResourceTiming(const ResourceTimingInfo&) = 0;
47 };
48
44 static PassRefPtr<ThreadableLoaderClientWrapper> create(ThreadableLoaderClie nt* client) 49 static PassRefPtr<ThreadableLoaderClientWrapper> create(ThreadableLoaderClie nt* client)
45 { 50 {
46 return adoptRef(new ThreadableLoaderClientWrapper(client)); 51 return adoptRef(new ThreadableLoaderClientWrapper(client));
47 } 52 }
48 53
49 void clearClient() 54 void clearClient()
50 { 55 {
51 m_done = true; 56 m_done = true;
52 m_client = 0; 57 m_client = 0;
58 clearResourceTimingClient();
53 } 59 }
54 60
55 bool done() const 61 bool done() const
56 { 62 {
57 return m_done; 63 return m_done;
58 } 64 }
59 65
66 void setResourceTimingClient(ResourceTimingClient* client)
67 {
68 m_resourceTimingClient = client;
69 }
70
71 void clearResourceTimingClient()
72 {
73 m_resourceTimingClient = nullptr;
74 }
75
60 void didSendData(unsigned long long bytesSent, unsigned long long totalBytes ToBeSent) 76 void didSendData(unsigned long long bytesSent, unsigned long long totalBytes ToBeSent)
61 { 77 {
62 if (m_client) 78 if (m_client)
63 m_client->didSendData(bytesSent, totalBytesToBeSent); 79 m_client->didSendData(bytesSent, totalBytesToBeSent);
64 } 80 }
65 81
66 void didReceiveResponse(unsigned long identifier, const ResourceResponse& re sponse, PassOwnPtr<WebDataConsumerHandle> handle) 82 void didReceiveResponse(unsigned long identifier, const ResourceResponse& re sponse, PassOwnPtr<WebDataConsumerHandle> handle)
67 { 83 {
68 if (m_client) 84 if (m_client)
69 m_client->didReceiveResponse(identifier, response, handle); 85 m_client->didReceiveResponse(identifier, response, handle);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 if (m_client) 133 if (m_client)
118 m_client->didReceiveResponse(identifier, response, nullptr); 134 m_client->didReceiveResponse(identifier, response, nullptr);
119 } 135 }
120 136
121 void didDownloadData(int dataLength) 137 void didDownloadData(int dataLength)
122 { 138 {
123 if (m_client) 139 if (m_client)
124 m_client->didDownloadData(dataLength); 140 m_client->didDownloadData(dataLength);
125 } 141 }
126 142
143 void didReceiveResourceTiming(const ResourceTimingInfo& info)
144 {
145 if (m_resourceTimingClient)
146 m_resourceTimingClient->didReceiveResourceTiming(info);
147 }
148
127 protected: 149 protected:
128 explicit ThreadableLoaderClientWrapper(ThreadableLoaderClient* client) 150 explicit ThreadableLoaderClientWrapper(ThreadableLoaderClient* client)
129 : m_client(client) 151 : m_client(client)
152 , m_resourceTimingClient(nullptr)
130 , m_done(false) 153 , m_done(false)
131 { 154 {
132 } 155 }
133 156
134 ThreadableLoaderClient* m_client; 157 ThreadableLoaderClient* m_client;
158 ResourceTimingClient* m_resourceTimingClient;
135 bool m_done; 159 bool m_done;
136 }; 160 };
137 161
138 } // namespace blink 162 } // namespace blink
139 163
140 #endif // ThreadableLoaderClientWrapper_h 164 #endif // ThreadableLoaderClientWrapper_h
OLDNEW
« no previous file with comments | « Source/core/loader/ThreadableLoaderClient.h ('k') | Source/core/loader/WorkerLoaderClientBridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698