         }
     }
 
+    private func finishedParsingJson(json: [String:[Int]]) {
+        delay(0) {
+            self.domainToIdMapping = json
+            self.checkBothLoadsAreComplete()
+        }
+    }
+
+    func fileLoader(loader: NetworkDataFileLoader, setDataFile data: NSData?) {
+        // synchronize code from this point on.
+        objc_sync_enter(self)
+        defer { objc_sync_exit(self) }
+
+        guard let data = data else { return }
+
+        if loader === targetsLoader {
+            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
+                do {
+                    guard let json = try NSJSONSerialization.JSONObjectWithData(data, options: []) as? [String:[Int]] else { return }
+                    self.finishedParsingJson(json)
+                } catch {
+                    print("Failed to load targetsLoader: \(error)")
+                }
+            }
+        } else if loader === rulesetsLoader {
+            loadSqlDb()
+            checkBothLoadsAreComplete()
+        }
+    }
+
     func fileLoaderHasDataFile(_: NetworkDataFileLoader) -> Bool {
         return false
     }

    lazy var rulesetsLoader: NetworkDataFileLoader = {
        let rulesetsDataUrl = NSURL(string: "https://s3.amazonaws.com/https-everywhere-data/\(dataVersion)/rulesets.sqlite")!
        let dataFile = "https-ruleset-\(dataVersion).sqlite"
        let loader = NetworkDataFileLoader(url: rulesetsDataUrl, file: dataFile, localDirName: "https-everywhere-data")
        loader.delegate = self
        return loader
    }()

    lazy var targetsLoader: NetworkDataFileLoader = {
        let targetsDataUrl = NSURL(string: "https://s3.amazonaws.com/https-everywhere-data/\(dataVersion)/httpse-targets.json")!
        let dataFile = "https-targets-\(dataVersion).json"
        let loader = NetworkDataFileLoader(url: targetsDataUrl, file: dataFile, localDirName: "https-everywhere-data-targets")
        loader.delegate = self
        return loader
    }()
