OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "ios/crnet/CrNet.h" | 5 #import "ios/crnet/CrNet.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
9 #import "ios/net/crn_http_protocol_handler.h" | 9 #import "ios/net/crn_http_protocol_handler.h" |
10 #import "ios/crnet/crnet_environment.h" | 10 #import "ios/crnet/crnet_environment.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 } | 52 } |
53 | 53 |
54 g_chrome_net->Install(); | 54 g_chrome_net->Install(); |
55 g_chrome_net->SetHTTPProtocolHandlerRegistered(true); | 55 g_chrome_net->SetHTTPProtocolHandlerRegistered(true); |
56 g_chrome_net->SetRequestFilterBlock(g_request_filter_block); | 56 g_chrome_net->SetRequestFilterBlock(g_request_filter_block); |
57 } | 57 } |
58 | 58 |
59 + (void)install { | 59 + (void)install { |
60 static dispatch_once_t onceToken; | 60 static dispatch_once_t onceToken; |
61 dispatch_once(&onceToken, ^{ | 61 dispatch_once(&onceToken, ^{ |
| 62 if (![NSThread isMainThread]) { |
| 63 dispatch_sync(dispatch_get_main_queue(), ^(void) { |
| 64 [self installInternal]; |
| 65 }); |
| 66 } else { |
62 [self installInternal]; | 67 [self installInternal]; |
| 68 } |
63 }); | 69 }); |
64 } | 70 } |
65 | 71 |
66 + (void)installIntoSessionConfiguration:(NSURLSessionConfiguration*)config { | 72 + (void)installIntoSessionConfiguration:(NSURLSessionConfiguration*)config { |
67 g_chrome_net->InstallIntoSessionConfiguration(config); | 73 g_chrome_net->InstallIntoSessionConfiguration(config); |
68 } | 74 } |
69 | 75 |
70 + (void)installWithPartialUserAgent:(NSString *)partialUserAgent { | 76 + (void)installWithPartialUserAgent:(NSString *)partialUserAgent { |
71 [self setPartialUserAgent:partialUserAgent]; | 77 [self setPartialUserAgent:partialUserAgent]; |
72 [self install]; | 78 [self install]; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 } | 135 } |
130 } | 136 } |
131 | 137 |
132 + (void)clearCacheWithCompletionCallback:(ClearCacheCallback)clearCacheCallback
{ | 138 + (void)clearCacheWithCompletionCallback:(ClearCacheCallback)clearCacheCallback
{ |
133 if (g_chrome_net) { | 139 if (g_chrome_net) { |
134 g_chrome_net->ClearCache(clearCacheCallback); | 140 g_chrome_net->ClearCache(clearCacheCallback); |
135 } | 141 } |
136 } | 142 } |
137 | 143 |
138 @end | 144 @end |
OLD | NEW |